How do I ignore blank lines when reading a txt file?
I'm trying to write a word count utility for internal use. All of my dialogue is in txt files in the Resources folder, so the utility just loads each file and splits them up accordingly. However, I can't figure out how to ignore line breaks. Here's my code:
string[] linesInFile = files[i].text.Split('\n')
.Where(theString =>
!theString.Contains("`title") &&
theString.Length > 0 &&
!theString.StartsWith(" "))
.ToArray();
When I print each string in linesInFile, I'm still seeing "blank" lines. There must be a character in there because the string's length is > 0, but I can't print it because the Unity console parses it as a space. Not sure if it's possible to print raw text to the console.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612170119im_/https://answers.unity.com/themes/thub/images/avi.jpg)