call defer to close opened file after make sure no err