Okay, let's do this:

```s
if (n > 1)
  x <- paste(x, rep(c("\n", ""), c(n - 1, 1)), sep = "")
```

i.e. do not add `\n` to the last line.