Added Cynthia's changes to the code
Removed trailing whitespace
Temporary file name is one that won't clash with others