I have:
o = File.new("ouput.txt", "rw+")
File.new("my_file.txt").lines.reverse_each { |line|
????? line
}
o.close
I don't know what method to use to write to the file output o
puts
understands arrays, so you can simplify this to:
File.open("f2.txt","w") {|o| o.puts File.readlines("f1.txt").reverse}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With