some rework with closing files, not right there, seems