Add close file function