Adding close and unlink to delete the temp file after use