Only close the grid file once