Fixed formatting causing newlines to be discarded

Fixes #1796