diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index 052e0a8..2a1c538 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -896,11 +896,12 @@ namespace Assignment_1 static List GetStringLines(string source, int maxWidth) { List lines = new(); - for (int i = 0; i < source.Length; i++) + int j = 0; + while (j < source.Length) { - int max = i + maxWidth <= source.Length ? i + maxWidth : source.Length; - lines.Add(source[i..max]); - i = max; + int max = j + maxWidth <= source.Length ? j + maxWidth : source.Length; + lines.Add(source[j..max]); + j = max; } return lines; }