Saving a .txt file to SD Card and Reading the txt file then save it to a variabl

I am new to arduino I am trying to create an arduino project that Saving a .txt file to SD Card and Reading the txt file then save it to a variable data type "Long" named 'savednum'. I had successfully can save the txt file and read it, however the problem lies in storing the read txtfile, when I read the txtfile and stored it in savednum and then serial print the savednum it gives different/ random numbers which is not equal to the data in the .txtfile that I store and read. I am wondering what seem to be wrong? Any suggestion is really appreciated. I thank you in advance.

 #include <TMRpcm.h>
 #include <SD.h>
 #include <SPI.h>
 #define SD_ChipSelectPin 4 //using digital pin 4 on arduino nano 328

 TMRpcm tmrpcm; // create an object for use in this sketch

File myFile;

char serialData;


int i = 0;
long n1 = 123456789;
long n2 = 245678918;

long savednum =0;


void setup()
{
Serial.begin(9600);
while (!Serial) {

 }



Serial.print("Initializing SD card...");

 if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("initialization failed!");
 while (1);
}
Serial.println("initialization done.");


 myFile = SD.open("NEWDATA.txt", FILE_WRITE);


if (myFile) {
Serial.print("Writing to NEWDATA.txt...");
myFile.println(n1);
myFile.println(n2);

myFile.close();
Serial.println("done.");
} else {

Serial.println("error opening NEWDATA.txt");
}    

myFile = SD.open("NEWDATA.txt");
if (myFile) {
Serial.println("NEWDATA.txt:");

while (myFile.available()) {
  Serial.write(myFile.read());  
// here the code I tried to read .txt file and store it in long   
savednum = myFile.read();
Serial.println(savednum);
}

myFile.close();

}


}




void loop()
 {

  }
while (myFile.available()) {
  Serial.write(myFile.read()); 
// here the code I tried to read .txt file and store it in long   
savednum = myFile.read();
Serial.println(savednum);
}

You wrote "123456789245678918" into the file.

Then, you read and write (why you are sending ACSII data in binary mode is a mystery) the '1' without using it in any way. Then, you read the '2', and store the one byte in a 4 byte variable, and then print that. You repeat that for the '3' and '4', the '5' and '6', the '7' and '8', the '9' and '', the '', etc.

Probably NOT what you meant to do.

You need to read and store all the characters, in an array, until you get a '', appending a NULL after each character. When you go get a '', call atol() with the array, and store the returned value in longnum, and then print that.