After running a cgi file and receving "internal server error" and looking at log iles, you'll receive "Premature end of script headers"
What does it mean ?
This error is usually caused by one of three things:
(1) The script file was created by a Windows program like Notepad and didn't get uploaded in Unix/ASCII format. Some FTP programs will translate Windows/DOS text files into Unix/ASCII on the fly with a proper setting. Otherwise you'll need a text editor that can save the files in the proper format on your computer.
(2) The script file's permissions were set improperly. Use the CHGMOD command in your FTP program to set the permissions on the script file to 755, or set it to allow Owner RWX permissions, Group RX permissions, and Other RX permission (where R = Read, W = Write, and X = Execute).
(3) There is a syntax error in the script. Often caused when a user customizes a public script for his site. All it takes is a stray keystroke, or an unescaped "@" to stop execution before it starts.(http://www.webmasterworld.com/forum13/4048.htm)
In order to avoid facing with this error for the second time, it's better to chage transfer type to ASCII (e.g. in Cute ftp select your domain , and in properties tab select Type and change Transfer Type)