Timeout: you can always change the scripts timeout value using set_time_limit().
For putting in the right line-ending characters, one way is to just read the file line by line (using fgets()) and then write a second copy of the file putting a \r\n on it:
// Caution: no error checking!
$in = fopen("data.in","r");
$out = fopen("data.out","w");
while ($line = fgets( $in, 65536 ))
{
fwrite( $out, chop($line) );
fwrite( $out,"\r\n" );
}