If you enter the while loop a second time, the stream has already been closed by a previous loop. linenum is not defined, but I presume you want your loop to go more than once. If so, move the...