Redundant file closing removed.