Read .txt file from SD and create a string

Hello.

I'm trying to read a .txt file from SD card, and convert the text into a string, then count how many characters are on this string.
I've accomplished reading the text file and sending it content through the serial monitor, And writing my own text on the serial monitor and convert it into a string, but i couldn't connect these two together.
My code so far:

#include <SD.h>
File myFile;
String txtMsg = "";
int relay = 2;
void setup() {
  Serial.begin(9600);
  pinMode(relay, OUTPUT);
  pinMode(10, OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
myFile = SD.open("1.TXT");
while (myFile.available()) {
    	Serial.write(myFile.read());
    }
  
}
void loop() {
  while (Serial.available() > 0) {
    char inChar = Serial.read();
    char inChar = Serial.read(myFile.read());
    txtMsg += inChar;
    int onTime=0;
    onTime=txtMsg.length()*100;
    digitalWrite(relay,HIGH);
     delay(onTime);
     digitalWrite(relay, LOW);
     txtMsg=0;
  } 

}

Any suggestions?

Thanks.

while (Serial.available() > 0) {
char inChar = Serial.read();
char inChar = Serial.read(myFile.read()); // this one is not good
txtMsg += inChar;
int onTime=0;
onTime=txtMsg.length()*100;

What are you trying to do ?

I'm trying to activate a relay depending on on the length of the string.
example:
if the text file is 10 characters long, the relay will be on for 1 second. (each character adds 0.1 second to onTime).

ontime=0;
if (Serial.available() > 0)  // same as  if(Serial.available())
{
   while (Serial.available()) 
   {
      char inChar = Serial.read(); 
      ontime+=100;
   }
}
if (ontime>0)  {do something}

I Still don't understand how to count the number of characters on the text file.
I'll try to explain my goal again:
I'm using arduino uno with ethernet+SD shield. The SD card holds a text file called "1.txt"
the text file contains 50 characters.
I Would like to create a program that reads the text file from the SD card and count the number of characters on it.
Then, for each character on the text file, add 100 to a integer counter.

thanks.

I'm trying to read a .txt file from SD card, and convert the text into a string, then count how many characters are on this string.

..now I dont see the problem.
Chars if a file (size) has it own function. Dont need to read the file to find how big it is..

Strings are implemented, but EATS memory when you start manipulating them.
Char-arrays is as easy to read data into.
If this char-array MUST be String. .> declare a String and set it eg. to char-array. (but why would you?)