Much more efficient getLastXLines()