How to read all data from text file

I am trying to read all the data from text file but it seems it only reads data from 1st 2 lines.
Heres my code

  static void ReadString()
    {
        string path = "Assets/Resources/Readme.txt";

        //Read the text from directly from the test.txt file
        StreamReader reader = new StreamReader(path);
        Debug.Log(reader.ReadToEnd());
    
        reader.Close();

How to read all the lines from a file

You might want to try this method:

or this one:

1 Like