That is a fairly generic error. When a CGI application sends a response to a browser, the first portion of the response must be a valid HTTP header. ' Best guess, is that there is a syntax error in your code and that the code is not actually running, but, is failing, thus, it does not produce the header and you get your error complaint.
HTH
keep the rudder amid ship and beware the odd typo