Am I missing something obvious? There are tons of other places where the line number of scanloc gets incremented.
Also I think instead of counting line numbers twice you should save the offset when you see a `#line nr "name"` and reset the offset for `#line`.