Read 50 characters
# Put some stuff into a file. open('sample_file', 'w') do |f| f.write("This is line one.\nThis is line two.") end puts open('sample_file') { |f| f.read(50) }