title: How to find duplicates in file
body: <p>Basically I want to try to make a system where when you type in your ID number, and do it again with the same number, it should show an error. I've tried to look for some solutions online, but just couldn't seem to find one that would actually work. This is the code I've done so far:</p>
  
  <pre><code>import sys
  N = 0
  while N &lt; 2:
      ID = input("Please input ID code ")
      if (len(ID)) == 6:
          with open('ID1.txt', 'a') as file:
              file.write(ID + ' ')
              file.write('\n')
          N += 1
          print("ID length: Valid")
      else:
          print("ID Code: Error")
          sys.exit()
  </code></pre>
  
  <p>Does anyone have any ideas on how to do it?</p>