How to open a file in Ruby and read its contents? By Alvin Lai November 19th, 2009 File.open(“myfile.html”, “r”) { |f| while str = f.gets puts str end }