Added missing close method calls for open files.