SD card read/write with Arduino

Hi

Thanks for the reply Cemath. Really sorry the late post. I tried out as you said. But still I am not getting the expected output. I found that increasing or decreasing the buffer size [ default 7 ] as no effect on the output. The only change is that suppose if I set buffer[10], then while reading the data, I get a junk character or symbol after each tenth character. So, I googled again and seeked help from other forums too. Finally I found the sdfatlib library doing the GPS logging and SDcard read/write functionality. Google Code Archive - Long-term storage for Google Code Project Hosting..
I tried the examples provided by that library and it worked fine. I was able to read data in char datatype. But since, the GPS sentences logged by GPS are of varied length due to absence of some fields, I had problems in parsing the sentence from the file and extracting the latitude and longitude alone for further processing.
So, I tried the otherway around and modified the GPS logging code[ SdFatGPSLogger example from the sdfatlib library] to log only the latitude and longitude into the sdcard textfile. I worked fine. The log file has contents like below,

13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1224,80.2223
13.1224,80.2223
13.1224,80.2223
13.1224,80.2223
13.1224,80.2223
13.1224,80.2223
13.1224,80.2223
13.1224,80.2222
13.1224,80.2222
13.1224,80.2222
13.1225,80.2222
13.1225,80.2222
13.1226,80.2222
13.1226,80.2222
13.1226,80.2222
13.1226,80.2222
13.1226,80.2222
13.1226,80.2222
13.1226,80.2221
13.1227,80.2221
13.1227,80.2221
13.1227,80.2220
13.1227,80.2220
13.1227,80.2219
13.1227,80.2219
13.1227,80.2218
13.1227,80.2218
13.1227,80.2217
13.1227,80.2217
13.1227,80.2216
13.1227,80.2216
13.1227,80.2215
13.1227,80.2215
13.1227,80.2214
13.1227,80.2214
13.1227,80.2214
13.1227,80.2213
13.1227,80.2213
13.1227,80.2213
13.1227,80.2213
13.1228,80.2213

Now, I stored this file in sdcard and tried to read it using the SdFatRead example. the example read the contents. Since, the file contents in each line are of same size, I used a fixed buffer size and used the comma delimiter to parse the data. I stored the latitude and longitude temporarily within the loop using two char arrays. I tried printing it as I read from the card. It worked.
Now, my problem is that , As I read the above data line by line from the card I need to compare it with another char array, so that If the arrays matches, I will send some data to print on the LCD display.
I used string functions. no use. Since the comparsion is between two char arrays, Inclusion of loops doesnot have data in it to compare. I really dont where is the mistake happening. I am stuck in this issue. I have posted the modified code here [ with no comparsion part] . Please help me out.

/*
 * This sketch reads and prints the file
 * PRINT00.TXT created by SdFatPrint.pde or
 * WRITE00.TXT created by SdFatWrite.pde
 */
 #include <stdio.h>
#include <SdFat.h>
#include <SdFatUtil.h>

Sd2Card card;
SdVolume volume;
SdFile root;
SdFile file;

// store error strings in flash to save RAM
#define error(s) error_P(PSTR(s))
void error_P(const char *str)
{
  PgmPrint("error: ");
  SerialPrintln_P(str);
  if (card.errorCode()) {
    PgmPrint("SD error: ");
    Serial.print(card.errorCode(), HEX);
    Serial.print(',');
    Serial.println(card.errorData(), HEX);
  }
  while(1);
}
void setup(void)
{
  Serial.begin(4800);
  Serial.println();
  Serial.println("type any character to start");
  while (!Serial.available());
  Serial.println();
  
  // initialize the SD card
  if (!card.init()) error("card.init");
  
  // initialize a FAT volume
  if (!volume.init(card)) error("volume.init");
  
  // open the root directory
  if (!root.openRoot(volume)) error("openRoot");
  
  // open a file
  if (file.open(root, "GPSLOG00.TXT", O_READ)) {
    Serial.println("Opened GPSLOG00.TXT");
  }
  else if (file.open(root, "WRITE00.TXT", O_READ)) {
    Serial.println("Opened WRITE00.TXT");    
  }
  else{
    error("file.open");
  }
  Serial.println();
  
  // copy file to serial port
  int16_t n;
//  uint8_t buf[19];// nothing special about 7, just a lucky number.
  char buf[15];
  char lat[8],lon[8];
  char temp;
int linecount=494,count=0; // char *latitude="13.1224",*longitude="80.2222";
  char array1[linecount][8],array2[linecount][8];
 while ((n = file.read((uint8_t *)buf, sizeof(buf))) > 0) 
  {
    for(int i=0;i<n;i++)
    {
     if(buf[i]!=',')
      {
        lat[i]=buf[i];
        Serial.print(lat[i]); // This place is where comparsion will occur
      }
      else
      {
        i=i+1;
        lon[i]=buf[i]; // This place is where comparsion will occur 
        Serial.print(lon[i]);
      }
    }
  }
  /* easier way
  int16_t c;
  while ((c = file.read()) > 0) Serial.print((char)c);
  */
 Serial.println("\nDone");
}

void loop(void) {}

My doubt may be silly. But please help me out since I need to complete the project as part of my academics.
Thanks in advance
Regards
N.Nandhakumar