changed flushing of stdout