fixed unclosed files, which would casuse >1000 accesses to fail in linux