check that file is not closed when destroying it