Count number of entries on SD card file (fixed but feedback is appreciated)

Hi all,

Ive managed to cobble a simple GPS datalogger together which records Latitude, Longitude and time in a CSV file on an SD card using the standard SD library. Each entry ends with a CR and LF. How does one go about counting the total number of entries on the SD card?

Any help is very much appreciated

Fred

EDIT: Managed to get it to work using the following code in setup():

File dataFile = SD.open("gpsdata.csv");
if (dataFile) {
  while (dataFile.available()) {
    char cardChar = dataFile.read();
    if (cardChar == '\n') {
      numberOfLogsTotal++;
    }
  }
  dataFile.close();
}
lcd.setCursor(0,0);
lcd.print(numberOfLogsTotal);
delay(5000);