I'm not sure why my Data logging code isn't working

For some reason I am not able to Write data to my SD Card. I'm not sure whats wrong with the code.


#include <SD.h>
#include <SPI.h>

#include <Wire.h>

File mySensorData;
int chipSelect = 63; 


String inputstring = "";                              //a string to hold incoming data from the PC
String sensorstring = "";                             //a string to hold the data from the Atlas Scientific product
boolean input_string_complete = false;                //have we received all the data from the PC
boolean sensor_string_complete = false;               //have we received all the data from the Atlas Scientific product


void setup() {    //set up the hardware
 pinMode(10, OUTPUT);
 SD.begin(chipSelect);

 
 Serial.begin(9600);                                 //set baud rate for the hardware serial port_0 to 9600
 Serial3.begin(9600);                                //set baud rate for software serial port_3 to 9600
 inputstring.reserve(10);                            //set aside some bytes for receiving data from the PC
 sensorstring.reserve(30);                           //set aside some bytes for receiving data from Atlas Scientific product
}


void serialEvent() {                                  //if the hardware serial port_0 receives a char
 inputstring = Serial.readStringUntil(13);           //read the string until we see a <CR>
 input_string_complete = true;                       //set the flag used to tell if we have received a completed string from the PC
}


void serialEvent3() {                                 //if the hardware serial port_3 receives a char
 sensorstring = Serial3.readStringUntil(13);         //read the string until we see a <CR>
 sensor_string_complete = true;                      //set the flag used to tell if we have received a completed string from the PC
}


void loop() {                                         //here we go...


 if (input_string_complete == true) {                //if a string from the PC has been received in its entirety
   Serial3.print(inputstring);                       //send that string to the Atlas Scientific product
   Serial3.print('\r');                              //add a <CR> to the end of the string
   inputstring = "";                                 //clear the string
   input_string_complete = false;                    //reset the flag used to tell if we have received a completed string from the PC
 }

 if (sensor_string_complete == true) {               //if a string from the Atlas Scientific product has been received in its entirety
   if (isdigit(sensorstring[0]) == false) {          //if the first character in the string is a digit
     Serial.println(sensorstring);                   //send that string to the PC's serial monitor
   }
   else                                              //if the first character in the string is NOT a digit
   {
     print_EC_data();                                //then call this function
   }
   sensorstring = "";                                //clear the string
   sensor_string_complete = false;                   //reset the flag used to tell if we have received a completed string from the Atlas Scientific product
 }
}


void print_EC_data(void) {                            //this function will pars the string

 char sensorstring_array[30];                        //we make a char array
 char *EC;                                           //char pointer used in string parsing
 char *TDS;                                          //char pointer used in string parsing
 char *SAL;                                          //char pointer used in string parsing
 char *GRAV;                                         //char pointer used in string parsing
 float f_ec;                                         //used to hold a floating point number that is the EC

 sensorstring.toCharArray(sensorstring_array, 30);   //convert the string to a char array
 EC = strtok(sensorstring_array, ",");               //let's pars the array at each comma
 TDS = strtok(NULL, ",");                            //let's pars the array at each comma
 SAL = strtok(NULL, ",");                            //let's pars the array at each comma
 GRAV = strtok(NULL, ",");                           //let's pars the array at each comma

mySensorData= SD.open("CPData.txt", FILE_WRITE);
if(mySensorData){
 Serial.print("EC:");                                //we now print each value we parsed separately
 Serial.println(EC);                                 //this is the EC value

 Serial.print("TDS:");                               //we now print each value we parsed separately
 Serial.println(TDS);                                //this is the TDS value

 Serial.print("SAL:");                               //we now print each value we parsed separately
 Serial.println(SAL);                                //this is the salinity value

 Serial.print("GRAV:");                              //we now print each value we parsed separately
 Serial.println(GRAV);                               //this is the specific gravity
 Serial.println();                                   //this just makes the output easer to read

//f_ec= atof(EC);                                     //uncomment this line to convert the char to a float

mySensorData.print(EC);
mySensorData.close();
}
}

Do you ever call print_EC_data? That's where the only file writing occurs.

If you do, why is most of the the data sent to the serial port rather than the file?

I send them to the serial port so that I can see if data is going into the sad card. Right now my sad card isn’t gathering any data and the file isn’t being created

void serialEvent3() {

Where is this function being called? If this function is never called, then your mother function is never executed.