Need to synchronize stdout and stdin for the benefit of Windows.
Must fflush stderr too--it's buffered on Windows!