Added method to close open files