To make it simple, I just change the logData() function as follow
void logData()
{
// make a string for assembling the data to log:
String dataString = "";
// if the file is available, write to it:
if (dataFile) {
dataFile.println("12345678");
dataFile.flush();
} else {
// if the file isn't open, pop up an error:
Serial.println("error opening datalog.txt");
}
delay(100); // run at a reasonable not-too-fast speed for testing
}