Multiple string replace in multiple files

Hi guys! Got a script:

or22=‘style.css’
rep22=‘stylea577.css’
Dir.glob “/home/alex/SITE/*.html”) do |file_name|
text = File.read(file_name)
replace=text.gsub!(or22, rep22)
File.open(file_name, “w”) { |file| file.puts replace }
end

It’s works fine, but second applying somehow makes affected html empty. Could please someone help me? Thanks!

in your code there is an error, a missing parenthesis, try with this:

or22 = 'style.css'
rep22 = 'stylea577.css'
Dir.glob('/home/alex/SITE/*.html') do |file_name|
  text = File.read(file_name)
  replace = text.gsub!(or22, rep22)
  File.open(file_name, 'w') { |file| file.puts replace }
end

Thanks, but nope.
That’s not it. Just losted while copying.
It’s something about gsub! and nil when no result.
But can’t figure out what I should use instead of gsub in this case…