Fixed a file close issue