It's difficult to say what your problem is without a code
sample; it sounds to big to post, here, though. However,
I can say that header must be printed before
any other output from the program. If you are printing
something else to STDOUT first, header
won't do its job.