in reply to Printing inside a loop

Output is buffered.

However you can disable that.