file handling cleanup