$ echo testing > testfile
$ irb
2.5.1 :001 > IO.read('testfile')
=> "testing\n"
Trying to understand where the newline is coming from as it's clearly not in the file.
$ echo testing > testfile
$ irb
2.5.1 :001 > IO.read('testfile')
=> "testing\n"
Trying to understand where the newline is coming from as it's clearly not in the file.
 
    
    But the newline is in the file, echo adds it. You can see for yourself with a hexdump:
$ echo testing > testfile
$ hexdump testfile 
0000000 74 65 73 74 69 6e 67 0a                        
0000008
That 0x0a is your newline.
And you can ask your shell (presumably bash) about echo:
$ help echo
echo: echo [-neE] [arg ...]
    Output the ARGs.  If -n is specified, the trailing newline is
    suppressed. [...]
So if you say echo -n testing > testfile, you'll get the results that you're expecting.
