How to count the number of lines in a text file