The output record separator for print() and cmd() is set to "\n" by default, so that you don't have to append all your commands with a newline. To avoid printing a trailing "\n" use put() or set the output_record_separator to "".