Please follow forum rules and post code/text inline, using code tags. Instructions here.
People using smart phones will often ignore posts that don't follow those rules.
By the way, it is a serious mistake to open the SD card data file, write a line or two of data, and then close it again. That vastly increases the current consumption of the project, the SD card error rate and can lead to brown outs and processor resets in some cases.
Open the file once in setup() and close it again when done writing data to the card. To protect data from unexpected shutdowns, every few minutes or hours issue a command like the following, to update the file pointers.
dataFile.flush();
To test correct RTC library function, replace the dataFile.print() statements with Serial.print() statements.