title: How can I sort out new lines in an older text file and overwrite to the other text file
body: <p>I'm receiving data by using php curl and saving them to a text file.
  It is automatically refreshing and writing data on old text.</p>
  
  <p>so, I tried to write a function that will sort out new* lines in an old* text file, and will save new* text file. But I falled apart. What can I do for it?</p>
  
  <blockquote>
    <p>old text file</p>
  </blockquote>
  
  <pre><code>line6) 6666666666
  line5) 5555566666
  line4) 4444444444
  line3) 3333333333
  line2) 2222222222
  line1) 1111111111
  </code></pre>
  
  <blockquote>
    <p>new curl data</p>
  </blockquote>
  
  <pre><code>line9) 9999999999
  line8) 8888888888
  line7) 7777777777
  line6) 6666666666
  line5) 5555566666
  line4) 4444444444
  line3) 3333333333
  line2) 2222222222
  line1) 1111111111
  </code></pre>
  
  <blockquote>
    <p>should be writen new lines to new text file</p>
  </blockquote>
  
  <pre><code>line9) 9999999999
  line8) 8888888888
  line7) 7777777777
  </code></pre>
  
  <hr>
  
  <p>the dublicate data that I dont want to use.
  here is an example that I already use. (Please read all line numbers carefully)</p>
  
  <pre><code>line9) 9999999999
  line8) 8888888888
  line7) 7777777777
  line6) 6666666666
  line5) 5555566666
  line4) 4444444444
  line3) 3333333333
  line2) 2222222222
  line1) 1111111111
  line6) 6666666666
  line5) 5555566666
  line4) 4444444444
  line3) 3333333333
  line2) 2222222222
  line1) 1111111111
  </code></pre>