change to close each file after loading it.
Reviewed tests: Fixed where broken and adjusted implementation logic to meet requirements.