Oh, I had a typo/thinko in my previous response - you were correctly counting from 0 to 98, but I wrongly suggested you should go up to $row[$counter][99] when I should have said 98. (So I think you should still be getting a few warnings.)
My output is: 1673
That's not what I get, but it isn't very far out. Maybe you could show the rest of the changes you made?
It would probably be more practical to start with a smaller grid, so that you can more easily see what the correct answer is - which would mean generalizing your code to discover the size when you read the input file, but that's a useful thing to do in any case. Then you could test your code against some simple cases, like:
222
222 (8 visible)
222
222
122 (9 visible)
222
222
221 (9 visible)
222
212
222 (9 visible)
222
222
222 (9 visible)
212
222
212 (8 visible)
222
22222
21112 (12 visible, test horizontal bounds)
22222
222
212
212 (12 visible, test vertical bounds)
212
222
etc.