avoid unlinking if tempfile is nil