Fixed issue when end of line cut off.
Note that
`str.length` might be not equal to `strlen(str.UTF8String)`.