in reply to Buffering File Output

This doesn't directly answer your question (that has been addressed already), but you should check out the BioPerl package, also available at bioperl.org. Among other things in this package, there are modules for parsing sequences in many formats (including FASTA) -- using these, your code will never need to search explicity for ">" to begin a line, and you will be able to think more about answering your questions and less about parsing the files. As a byproduct, your code will be much simpler to read and maintain, and problems (like this one) will be easier to track down and debug.

Good luck!