Clean up this Ruby code under DRY principle
puts "Blurt out a word"
word_list = []
while word_list.last != ""
  word_list &lt;&lt; gets.chomp
end
puts word_list.sort


If you prefer the until:

puts "Blurt out a word"
word_list = []
until word_list.last == ""
  word_list &lt;&lt; gets.chomp
end
puts word_list.sort


You can also do it shorter:

puts "Blurt out a word"
word_list = []
word_list &lt;&lt; gets.chomp until word_list.last == "" 
puts word_list.sort


Remark: The last (empty) line is also returned. To skip the empty line you may use:

puts word_list[0..-2].sort