Fixed closing files