title: Print the number of line in a python difflib file
body: <p>I am trying to find the difference between 2 text files using difflib in Python. I am able to print text which have been added or removed in the new file. But I want to print in which line the modification has been made. Even though I know how to count the number of lines in the file, I am unable to print the lines which have been added or removed. My code is here :</p>
  
  <pre><code>import difflib
  import time
  
  
  def get_diff(old_file, new_file):
      f1 = open(old_file, 'r')
      f2 = open(new_file, 'r')
  
      old_file = f1.readlines()
      new_file = f2.readlines()
  
      diff = difflib.unified_diff(old_file, new_file, lineterm='')
      lines = list(diff)[2:]
      added = [lineA for lineA in lines if lineA[0] == '+']
  
  
      with open("output.txt", "w") as fh1:
       for line in added:
         fh1.write(line)
      print '+',added
      removed = [lineB for lineB in lines if lineB[0] == '-']
      with open("output.txt", "a") as fh1:
       for line in removed:
         fh1.write(line)
      print '-',removed
  
  
  if __name__ == '__main__':
      fh = get_diff("ex.txt","ex2.txt")
  </code></pre>
  
  <p>Thank you in advance :)</p>