strategically inserts newlines where appropriate