Removing the last element of the string got it resolved.
Might not be the best way and adding additional check for carriage return before removing the element would be better, so this is only initial proof.


Improved example with the above comments resolved.

testingGround.d
import std.stdio;
import std.algorithm;



int lineNumber;
void main(){

        File exampleFile = File("exampleText.txt");
        lineNumber = 0;
        foreach(line; exampleFile.byLine){
                
                if (line == " Sphinx of black quartz, judge my vow.\u000D"){
                        if (line[line.length -1] == '\u000D'){
                                line = line.remove(line.length - 1);
                        }
                        writeln(lineNumber, ". hahahahahahaha", line, " 
nononono");
                        
                } else {
                        writeln( lineNumber, ". ", line[line.length -1]);
                }
                
                lineNumber++;
        }
}

Reply via email to