fixed closing order error
open files inside for when loading