Finished code to properly read in the grid.