Change lastLine API, fix lastLine '\n' bug