Move presentation logic to the correct place
Make the line number detection less fragile
Coding style
Improve the list formatter