Change your code to:
until (word = gets.chomp).empty?
The way you're doing it now:
(word = gets).to_s.chomp.empty?
gets
the string from the keyboard input, but it isn't returned to your code until the user presses Return, which adds the new-line, or carriage-return + new-line on Windows.
to_s
isn't necessary because you're already getting the value from the keyboard as a string.
chomp
needs to be tied to gets
if you want all the input devoid of the trailing new-line or new-line/carriage-return. That will work fine when testing for empty?
.