SD Card Write Issue

Hi,

I am trying to log the time and RFID data to an SD card.

Both the time and the volatge are being save perfectly, but the RFID data is preceeded by some rubbish data, which i cannot figure out where it is comming from.

Below is the segment of the code where RFID Tag is read and then saved,

    char rfidData[BUFSIZE];  // Buffer for incoming data
    rfidData[0] = 0;         // Clear the buffer
    char offset = 0;         // Offset into buffer      

    while (mySerial.available()) {
        byte C = mySerial.read();
        rfidData[offset] = C;
        offset++;
        int Count = offset;
        Serial.print(C);
        Serial.println("LOOKING FOR TAG");
        }
        if(offset == 17){
          count = 0;
          //Serial.print("Reader has detected the TAG # ");
          //Serial.println(rfidData);
          
          
          DateTime now;   //?????
          // fetch the time
          now = RTC.now();
          // log time
          //  logfile.print(now.unixtime()); // seconds since 1/1/1970
          //  logfile.print(", ");
          logfile.print('"');
          logfile.print(now.year(), DEC);
          logfile.print("/");
          logfile.print(now.month(), DEC);
          logfile.print("/");
          logfile.print(now.day(), DEC);
          logfile.print(" ");
          logfile.print(now.hour(), DEC);
          logfile.print(":");
          logfile.print(now.minute(), DEC);
          logfile.print(":");
          logfile.print(now.second(), DEC);
          logfile.print('"');
          #if ECHO_TO_SERIAL
          
          //logfile.print('"');
          //logfile.print(", ");
          logfile.print(", ");
          logfile.print('"');
          Serial.println(rfidData);
          logfile.print(rfidData);
          logfile.print('"');

Attached also is a screen shot of the data in the excel file.

Does anyone know what may be going on here?

Many Thanks, Micheal.

I seem to have resolved this issue,

          int j;
          for(j = 0; j <= 15; j++){
            logfile.print(rfidData[j]);
            Serial.print(rfidData[j]);
          }