Make sure creating the temporary file was successful.
Clean temporary files as soon as possible.

You don't want to leave trash, even if this is PHP.