[Solved] Merging Lines of text where string ends in a specific condition


Here is a working solution that was developed

for (var i = 0; i < Lines.Length; i++) {
    Builder.Append(Lines[i]);
    
    if (Lines[i].EndsWith(" and") || Lines[i].EndsWith(" of") ||
        Lines[i].EndsWith(" for") || Lines[i].EndsWith(" at") ||
        Lines[i].EndsWith(" the")) {
        
        if (i < (Lines.Length - 1)) {
            Builder.Append(" ").Append(Lines[i + 1]);
            i++;
        }
    }
        
    Builder.AppendLine("");
}
return Builder.ToString();

solved Merging Lines of text where string ends in a specific condition