Cgi files must be transferred in 'Text' or 'ASCII' mode and NOT in 'Automatic' or 'Binary' mode. Otherwise you will find the cgi file corrupted and it will produce an error.