while line=gets.chomp do # Loop, asking the user for input each time case line when /^\s*#/ next when /^quit$/i break else puts line.reverse end end