Probably overkill for a one-liner, but for something longer you can control flushing with the flush/autoflush-related functions/methods from
.
edit: one nice thing about this approach is that you can specify how different file handles get flushed. For example, auto-flushing log files only gives you up-to-date logs, but doesn't cause the performance penalty of auto-flushing file handles used for big data.