Removed unused function
Formatting
Log failure to close into log file as well as stderr