Fixed unclosed files at the start of the simulation