Add trailing newlines where appropriate