fixed regression in previous commit, and bug in newline counting