Fixed a bug with closing file readers/writers.