I suspect that if you change puts line
to puts line.inspect
you will see the problem.
Found it? gets
reads by lines, which includes the line-terminating \n
, so no line you get will ever equal "/close "
. Changing the comparison to use line.strip
will work, for example.