Added a check in single-line algorithm to make sure last character rendered.