Fix to resolve #946

Please review the fix and let me know if it does good.
`tempFile` cannot be `null`