title: Remove line of text from file on ruby
body: <p>I have a txt file with a series of strings on each line. I need to find for a given string, move that string to another file and remove that line from the file. </p>
  
  <p>Moving to another file is working, this is the code.</p>
  
  <pre><code>File.open('file_moved.txt', 'w') { |file| file.puts pick_random_line.to_i.to_s }
  
  def pick_random_line
    chosen_line = nil
    File.foreach("file.txt").each_with_index do |line, number|
    chosen_line = line if rand &lt; 1.0/(number+1)
    end
    chosen_line
  end
  </code></pre>
  
  <p>I'm a bit lost in how to remove the line from the other file. What would be the method in Ruby to remove the complete line with the matched string?</p>