refactor the code, close file even if the exception is thrown
1.5.2 release