Fix the unlit path in count_lines
Improve error message

Accommodating Simon M's suggestion (Trac #4268, comment 17)