add newline only if string does not already end with one

- keeps tests passing