Fixed issue when end of line cut off.

Note, that `str.length` might be not equal to `strlen(str.UTF8String)`

This bug also reported by @fonkadelic at #2.