in reply to Why does my CGI script sometimes first show headers and then content?
Solved.
The webserver is using some kind of CGI-wrapper. When it times out after 15 seconds all hell breaks loose.
Nothing to do with my scripts after all!
Thanks anyway.