(FIXED) TextAsset.name is never equal to compared string

so here’s the problem.
i’m trying to load text assets based on a list of file names (in this case its simple config files for weapons).
first off i was loading them from an external file using a streamReader, which was working perfectly and still does.
now, i’m trying to do the same thing using textAssets imported into unity.
the problem is that when i try to compare the ‘name’ of some of the textAssets to the list of names that i have, they never return true. no matter what.

i’ve been pulling my hair out for hours over a simple:
is “weapon” == “weapon”? nope.
i’ve debugged the hell out of it and the strings i am trying to compare are 100% equal, yet they never return true.

here is part of my code:

for (int a = 0; a < SaveManager.defaultSaves.Length; a++){
	Debug.Log(SaveManager.defaultSaves[a].name + "_" + fileName);
	if(SaveManager.defaultSaves[a].name == fileName){

alt text

there are definitely no extra spaces or anything like that.
this is driving me insane.
worst part is that it actually does work in other scenarios.
just not this one for god knows what reason.

i can’t even really think of what an answer to this would even be, there seems to be no reason as to why these aren’t working.

here’s some more of the code:

	private static bool Load(string fileName, bool useDefault){
		if(!useDefault){
			try{
				string line;
				string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
				string file = dir + @"\data\" + fileName + ".txt";
				StreamReader theReader = new StreamReader(file, Encoding.Default);

				using (theReader){
					do{
						line = theReader.ReadLine();
						
						if (line != null){
							if(line.Length != 0){
								if(line[0] != '/')
									SaveManager.data.Add(line);
							}
						}
					}
					while (line != null);
					theReader.Close();
					return true;
				}
			}

			catch (IOException e){
				Debug.Log("" + e.Message);
				return false;
			}
		}
		else{
			for (int a = 0; a < SaveManager.defaultSaves.Length; a++){
				Debug.Log(SaveManager.defaultSaves[a].name + "_" + fileName);
				if(SaveManager.defaultSaves[a].name.ToString() == fileName.ToString()){
					string[] lines = SaveManager.defaultSaves[a].text.Split("

"[0]);
for (int i = 0; i < lines.Length; i++){
if (lines != null){
_ if(lines*.Length != 0){_
_ if(lines[0] != ‘/’)
SaveManager.data.Add(lines);
}
}
}
return true;
}
}
Debug.Log("file not found: " + fileName);
return false;
}
}
FIXED!
i added a new line of code:_

lines _= lines.Trim();*
turns out it problem was caused \r characters.
using Trim() removed any \r characters and fixed the issue._

@robertbu
thank you so much!
it worked!
i looked up on ‘\r’ usage and found the Trim() method, and then added a new line of code:
lines = lines*.Trim();*
and now it works!