remove carriage returns and change tmp file creation