Correct 2D array iteration for data reading