title: Remove a string from a Ruby file when it matches a regex
body: <p>I'm writing a little script in Ruby that removes comments from Ruby files:</p>
  
  <pre><code>#!/usr/bin/ruby
  
  def uncomment(file)
    File.readlines(file).each do |line|
      if line =~ /(^\s*#|^\t*#)(?!\!).*/
        puts line + " ==&gt; this is a comment"
  
        #todo: remove line from the file
  
      end
    end
  end
  
  
  puts "Fetching all files in current directory and uncommenting them"
  # fetching all  files
  files = Dir.glob("**/**.rb")
  # parsing each file
  files.each do |file|
  
  
    #fetching each line of the current file
    uncomment file
  
  end
  </code></pre>
  
  <p>I am stuck on how to remove these lines that match the regex in the #todo section, it would be great if someone could help!</p>