Thanks feherke,
I'm running awk that's supplied with Mac OS X 10.4.10. I think there was some hidden junk at the end of my file or something, because when i re-generated the input file, the awk script worked.
I agree a dedicated counter would be better than my crummy slow code!
wc works, but i...