Fix bug in UpdateLineEnd