HTTP headers are delimited by \r\n, not \n.
In reply to Re: Premature end of script headers by Corion in thread Premature end of script headers by zitic