in reply to Is there a way to control when output gets printed to a file?
See Mark-Jason Dominus' Suffering from Buffering