ADXL 345 & Adafruit SD data logger_ how to merge the two working codes together?

Hi folks

I'm attempting pretty much exactly what this thread started out as. Alot of the same code even. My issue is that though the unit is working and outputing everything to the serial monitor (the accelerometer is outputting correctly on all three axis) including headers, as well as creating the file on the SD card (as well as properly changing the name of the file each time I activate the process) it is not actually saving any of the accelerometers data to the excel files it is creating. So I have a bunch of 0KB excel files at the end of my tests. I've been working on this for quite a while now, and figure it's time to ask for help. If anyone has the time to look at my sketch (and hopefully find one or more rookie errors...) I'd very much appreciate the help!! Judging by previous posts I'll post the entire code, lots of it will look familiar, it's a combo of the code from Adafruit and a page called Live Fast Code Young. I've gone cross-eyed at this point, thank you in advance! (and sorry about the massive code dump...)

#include "SD.h"
#include <Wire.h>
#include "RTClib.h"

#define LOG_INTERVAL  100 //milliseconds between entries
#define ECHO_TO_SERIAL  1 //send data to serial port? 1=yes 0=no
#define WAIT_TO_START  1 //require a character to be sent to the serial monitor to activite the monitor? 1=yes 0=no 
#define DEVICE  (0x1D) //wiring the adxl345 will dtermine wether this is 0x53 or 0x1D
#define TO_READ  (6) //num of bytes we are going to read each time (two bytes for each axis)


byte buff[TO_READ];
char str[512];

RTC_DS1307 RTC; // define the Real Time Clock object  
// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10; 
// the logging file
File logfile; 

void setup()
{
  Serial.begin(9600);
  Serial.println();

#if WAIT_TO_START
  Serial.println("Type any character to start");
  while (!Serial.available());
#endif //WAIT_TO_START

  // intialize the SD card
  Serial.print("Initializing SD card. ");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);

  // see if the card is present and can be initialized:  
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:    
    return;  
  }  
  Serial.println("Card initialized.");

  // create a new file  
  char filename[] = "LOGGER00.CSV";  
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
      // only open a new file if it doesn't exist
      logfile = SD.open(filename, FILE_WRITE);
      break;  // leave the loop!    
    }  
  } 

  Serial.print("Logging to: ");
  Serial.println(filename);



  Wire.begin();

  writeTo(DEVICE, 0x2D, 8);  //turn on adxl345

  if (!RTC.begin()) {
    logfile.println("RTC failed");
#if ECHO_TO_SERIAL
    Serial.println("RTC failed");
#endif //ECHO_TO_SERIAL
  }

  logfile.println(" Time , X , Y , Z ");
#if ECHO_TO_SERIAL  
  Serial.println(" Time , X , Y , Z ");
#endif
}    



void loop()
{
  DateTime now;

  //delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));

  // fetch the time
  now = RTC.now();
  //log time
  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);
#if ECHO_TO_SERIAL
  Serial.print(", ");
  Serial.print(now.year(), DEC);
  Serial.print("/");
  Serial.print(now.month(), DEC);
  Serial.print("/");
  Serial.print(now.day(), DEC);
  Serial.print(" ");
  Serial.print(now.hour(), DEC);
  Serial.print(":");
  Serial.print(now.minute(), DEC);
  Serial.print(":");
  Serial.print(now.second(), DEC);
#endif //ECHO_TO_SERIAL

  int regAddress = 0x32;  //first axis-acceleration-data register on the ADXL345

  int x, y, z;

  readFrom(DEVICE, regAddress, TO_READ, buff);  //read the acceleration data from the ADXL345
  
  //each axis reading comes in 10 bit resolution, ie 2 bytes.  Least Significat Byte first!!
  //thus we are converting both bytes in to one int
  x = (((int)buff[1]) << 8) | buff[0];
  y = (((int)buff[3]) << 8) | buff[2];
  z = (((int)buff[5]) << 8) | buff[4];
  
  //we send the x y z values as a string to the serial port
  sprintf(str, " %d %d %d", x, y, z);
  logfile.print(str);
  logfile.write(10);
#if ECHO_TO_SERIAL 
  Serial.print(str);
  Serial.write(10);
#endif                  //It appears that a delay is needed in order not to clog the port

  delay(15);
}


//Functions


void writeTo(int device, byte address, byte val)  {
  Wire.beginTransmission(device);        //start transmission to device 
  Wire.write(address);                    // send register address
  Wire.write(val);                       // send value to write
  Wire.endTransmission();              //end transmission
}

void readFrom(int device, byte address, int num, byte buff[])  {
  Wire.beginTransmission(device);      //start transmission to device 
  Wire.write(address);                  //sends address to read from
  Wire.endTransmission();             //end transmission

    Wire.beginTransmission(device);      //start transmission to device (initiate again)
  Wire.requestFrom(device, num);         // request 6 bytes from device

  int i = 0;
  while(Wire.available())            //device may send less than requested (abnormal)

  {
    buff[i] = Wire.read();           // receive a byte
    i++;
  }
  Wire.endTransmission();            //end transmission
}