Only remove leading spaces

This was incorrectly removing newlines too which was resulting in
incorrect formatting