opens text.txt and then passes the file handle into the code block as f. File.open("text.txt") do |f| puts f.gets end