Corrected to count lines correctly.