Refactoring ToTempFile