Flush stdout when all input has been read