Prova così:
codice:
$content = file('filetotrim.txt');
$output = '';
foreach($content as $k => $line)
{
  $output .= str_replace(' ', ':', $line)."\n";
  unset($content[$k]);
}

echo $output;