ensure that files get closed