An error message is now printed and the program terminates if the grid size is invalid