yet char manipulation question

Hi,
I have a question from my old, working code (by now from this Forum I learned to code by char and not String). In NON working code, I got Arduino read a text file from SD card that contains an ssid in first line and password on the second line, nothing else. It reads this way:

          String info;
    while (myFile.available()) {
      info += (char)myFile.read();
    }

then to send it to ESP8266, I wrapped ssid and password:

if((idx = info.indexOf('\n')) != -1){
        ssid = info.substring(0, idx);
        pass = info.substring(idx + 1);
        wifisp = "@@y,"+ssid+","+pass+"&$";
      }

and it didn't work! By testing and guessing that Arduino did NOT read like "Line1+'\n'+Line2", BUT it read like "Line1+'\r'+'\n'+Line2", I edited the code, adding:
ssid = ssid.substring(0,ssid.length()-1);

ending with:

if((idx = info.indexOf('\n')) != -1){
        ssid = info.substring(0, idx);
        pass = info.substring(idx + 1);
        ssid = ssid.substring(0,ssid.length()-1);
        wifisp = "@@y,"+ssid+","+pass+"&$";
      }

and this time it worked.

Now could anyone please make me clear if my guess is correct, or there is some other thing doing the magic there please?

The file is not likely to contain JUST \n between records. It is more likely to contain \n and \r in some order.

Your second block of code is stripping one more character - the \r from the ssid.

There are three styles of line-end

Unix style; linefeed ('\n')
DOS/Windows style; carriage return ('\r') followed by linefeed ('\n');
Mac style (maybe old mac style); carriage return ('\r')

I'm not sure if newer Macs differ from the older ones; they may use the Unix style.

So it depends on the system that the file was created on. Proper code should handle both.

As my OS is Windows 7 and I created the file with the default notepad of it, it must be '\r\n', clear.

Thank you very much!