I\'d like to add a single line to the top a of file with Ruby like this:
# initial file contents something else # file contents after prepending \"hello\" o
fwiw this seems to work:
#!usr/bin/ruby f = File.open("myfile", "r+") lines = f.readlines f.close lines = ["something\n"] + lines output = File.new("myfile", "w") lines.each { |line| output.write line } output.close