trimmed output and added a new line to eof