File Directory Ruby

check = IO.popen("spell","r+")
check.puts("A")
check.puts("D")
check.close_write
list = check.readlines
list.collect! { |x| x.chomp }