The attached vi will open a file, get the EOF location, then read lines from a file until EOF is reached. The iteration counter, i, will contain one less than the number of lines that was read, because i starts with 0. Just add 1 to i after the loop and viola, you have the number of lines in a file. Beware, if the file does not contain any end of line constants, there will be an error. You could easily trap that error and report the number of lines as zero. Or if you get the error and the string length from the read function is greater than zero, you might want to count that as one line.