[WO-341] Make sure that there is no infinite loop when folding

Currently when a line was one constant stream of characters, the folding function went into infinite loop when trying to figure out the next place to fold at (always resulted to the same place). This method fixes it