Added flushing to sys.stdout