Create temporary file only when needed
Remove temporary file only if it was created