#!/usr/bin/perl

foreach my $file (@ARGV)
  {
  open FILE_IN, "<$file" or die "Unable to read file $file: $!\n";
  open FILE_OUT, ">$file~" or die "Unable to write file $file~: $!\n";

  while (<FILE_IN>)
    {
    s/\r/\n/g;
    printf FILE_OUT;
    }

  close FILE_IN;
  close FILE_OUT;

  rename "$file~", "$file" or warn "rename $file~ to $file failed: $!\n";
  }
