- exception handling of case when temporary file cannot be opened

- exception handling of case when temporary file cannot be opened
- make sure that temporary file handle is closed before attempting to remove temporary directory