count_lines("c:\myfile.csv") FUNCTION count_lines LPARAMETERS tcFilename LOCAL lnHandle, lnLines, lcData * Validate parameter IF TYPE("tcFilename") != "C" OR NOT FILE(tcFilename) MESSAGEBOX("Usage: lines filename.ext", 0 + 64, "Count Lines") CANCEL ENDIF * Open the file lnHandle = FOPEN(tcFilename, 10) IF lnHandle <= 0 MESSAGEBOX("Error opening " + tcFilename, 0 + 64, "Count Lines") CANCEL ENDIF * Count the lines lnLines = 0 DO WHILE NOT FEOF(lnHandle) lcData = FREAD(lnHandle, 65535) lnLines = lnLines + OCCURS(CHR(13), lcData) ENDDO FCLOSE(lnHandle) * Report MESSAGEBOX("File contains " + LTRIM(TRANSFORM(lnLines, "999,999,999")) + " lines.", 0 + 64, "Count Lines")You may need to load the file into a hex editor and see what the end-of-line characters are. Some systems use CHR(13), some use CHR(10), some use CHR(13)+CHR(10), some use CHR(10)+CHR(13). Windows typically uses either CHR(13) or CHR(13) + CHR(10), so by counting only CHR(13) instances, you will accommodate both. But, it can still be off if the line-ending form is non-standard.