Poignant guide example chapter 4 - gsub

Hi,
I’m new to ruby and have a doubt in the below example from poignant
guide chapter 4.

I want to know why the each loop is needed in this example?
CODE_WORDS.each do |real, code|
idea.gsub!( real, code )
end

the code worked fine without it.
Can someone help me understand what i’m missing here.

CODE_WORDS = {
‘starmonkeys’ => ‘Phil and Pete, those prickly chancellors of the New
Reich’,
‘catapult’ => ‘chucky go-go’, ‘firebomb’ => ‘Heat-Assisted Living’,
‘Nigeria’ => “Ny and Jerry’s Dry Cleaning (with Donuts)”,
‘Put the kabosh on’ => ‘Put the cable box on’
}

Get evil idea and swap in code words

print "Enter your new idea: "
idea = gets
CODE_WORDS.each do |real, code|
idea.gsub!( real, code )
end

Save the jibberish to a new file

print "File encoded. Please enter a name for this idea: "
idea_name = gets.strip
File::open( “idea-” + idea_name + “.txt”, “w” ) do |f|
f << idea
end

Thanks,
Priya