Thanks for the info in SS Tim. I had the same problem as you have storing data to SD card. I don't now know exactly what fixed the problem. Evidently, changing pinMode(SS, OUTPUT); to "pinMode(chipSelect, OUTPUT);" was not the fix. I just went back to my code and tried "pinMode(SS, OUTPUT);". Either one works.
I used a different string conversion:
char data[50];
sprintf(data, "%d,%d,%d,%d,%d", count,x,y,z,MeasurementError);
dataFile.println(data);
dataFile.flush(); // write to SD card
I would use the flush() command after each dataFile.print and close the file at the end.
Gerry