Added handling of case when exception is thrown when input file is closing