This shouldn't be necessary as stdout is already locked by libc (see comment.) Not sure which part isn't working.