names=IO.readlines("C:\\customer_details1.txt") count=names.length for i in 0...count puts "The contents of the file are #{names[i]}" end rescue $stderr.puts "error" puts "The error occurred is #{$!}"end