Correct use of tempfile