dont know how to output this

Given a square matrix, write a program that determines the number of white(numbered) blocks and total number of squares in each of the white blocks. By definition, the outside boundaries of the matrix must be shaded(0). A block of white squares consists of all of the white squares whose side boundaries are next to another white square. White squares that touch only a diagonal point are not adjacent. Accommodate a maximum of 10 blocks and a maximum matrix of 10 x 10 .
In the diagram below, block 1 contains three squares, and block 4 contains nine squares. Note that block 3 contains only one square. It touches block 1 only on the diagonal.

I cannot read the file that you've got on your computer. I can only guess from the 3 or so attempts at file input to divine what the contents of your file actually look like. In order for good help with the reading of your input file, again, could you post the actual contents of this INPUT (not the source) file?!

Right. That's the one I meant. You input into row1, but not into row2, row3, etc. -- yet you try to output from them to the screen and not to the output file. And why do you try to read a filename from the file if the file does not contain a filename? And before we get too far into it let me look for the post about not controlling a loop with eof :http://www.daniweb.com/techtalkforums/post155265-18.html

[Oops. That link also gives heavy hints on how to do what you are trying to do.]