in reply to Checking if a header has been printed
A whole 'nother approach would be to not print anything at all in the guts of your program, instead stashing away all of your header (and possibly content) data until the very end, where everything gets printed at once.