While loop does only 1 loop and does not repeat the block of codes under it. Can someone please explain why this is happening?
puts "Enter your text:" text = gets.chomp text.downcase! puts "How many words do you have to hide?" num = gets.to_i red_text = "" while num > 0 puts "Word to be kept secret:" redact = gets.chomp! redact.downcase! words = text.split (" ") words.each do |word| if word != redact red_text.concat(word + " ") else red_text.concat(" REDACTED ") end num -= 1 end puts red_text end