flush stdout to write