debugging; fixed file close error