My error was in failing to unwrap lines.
Meh; duh!
Thanks for putting me on the right track.
In reply to Re^4: getting line count in cmd.exe by ww in thread getting line count in cmd.exe by chuckd