Improved line generation to avoid line end overlapping