move temp file deletion such that files don't stick around after running the script, also get rid of program-exit error