Question: How come? I thought that "+1" is the lowest number it can generate... This is the question:

"(int) Math.random()\*(65535 + 1) returns a random number between:
Between 0 and 65535. <- answer

This is a question from a sololearn challenge.

Answer: 
Just pass `-n` and it should fix that.

`$ssh->write("echo -n '$file' > /directory/test.txt\n");`

`-n` tell not to append a new line.
I'm not sure why `write()` was sending additional line breaks. I'm sure if I went line by line and appended to the file that would have worked. In the end, I simply used `SFTP::put()` which allowed me to place the `@` that which wouldn't work with `SSH::exec()`. Thanks for all the input - it's a little different method than I would have liked, but it works.