Ensured all unmanaged open files are closed to prevent resource warnings