title: Logic for a file compare
body: <p>I trying to write a programm for file compare. For example:</p>
  
  <p>file1</p>
  
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  
  <p>file2</p>
  
  <pre><code>1
  2
  @
  3
  4
  5
  </code></pre>
  
  <p>If I do it line by line, I get:</p>
  
  <pre><code>1 == 1; 
  2 == 2;
  3 != @;
  4 != 3;
  5 != 4;
    != 5;
  </code></pre>
  
  <p>But, the truth is that the only difference between the files is @. I want get something like this:</p>
  
  <pre><code>1 == 1;
  2 == 2;
    != @;
  3 == 3;
  4 == 4;
  5 == 5;
  </code></pre>
  
  <p>Which is the best way to do it?  without using any external application, such as diff, fc, etc.</p>