Remove redundant trailing newlines