compacting function no longer ignores last value in lines array