While the file handle does not contain the data for the file, it is quite easy to construct a for loop to read through and count each of the lines in a file: The rough translation of the for loop into...While the file handle does not contain the data for the file, it is quite easy to construct a for loop to read through and count each of the lines in a file: The rough translation of the for loop into English is, "for each line in the file represented by the file handle, add one to the count variable." If you know the file is relatively small compared to the size of your main memory, you can read the whole file into one string using the read method on the file handle.