in reply to Counting between the lines

Nit: the solutions that print a final line after the while loop will fail if there are no words.