Fix extra newlines in some situations

Spotted by Martin Boer.