close file to avoid resource leak