Fix scope of tmp file variables