fixed closing of file