Write output in line number order.