in reply to Flushing the print buffers.
If you run the program from the command line, add a newline (\n) to the end of your print statements. STDOUT uses line buffering when connected to an active terminal.