Add or remove newlines where necessary.