You can read an entire file into an array, split by lines, using readlines:
puts File.open("main.rb").readlines.join("--")
The "newline" characters that are present at the end of each line of the file are not removed.