print $fh $data, "\n"; # append a line break. You'd use "\r\n" on windows.