Try and provide a little more information, it will help us work out what solution best fits your needs:
  1. How many invoices are you talking about?
  2. How are you doing the check to see if the invoice is in the file?
  3. Are the invoices sorted in the file before you start?
  4. How / when is the program run?
  5. Can you post your code?