correct calculation for number of lines

A final \n in a <pre> is not rendered by browsers, so we shouldn't
include it in the calculation for the number of lines.

Fixes #382.