count lines a little more efficiently