Made sure temp file is closed before attempting to delete it.