fixing issue with unclosed file