agree, want to avoid opening/closing files repeatedly. buffering works, or just leave the file open and write repeatedly. 

@gregcaporaso i think a few years ago we had a discussion on buffering vs. just writing, where i was advocating buffering and you were advocating just writing. i did some tests a bit ago and couldn't see a noticable difference. i suspect the python file objects buffer by default (then there are of course the OS buffers as well)