fix a crash when the length or location of lastLine is 0