Use Readline.readline(). That’s what irb uses for user input.

Don’t use gets.chomp.