EDBEngineError 'Key Violation'


    I Have the following code:

procedure TFS_Starting_Form.mLoadFiles(Tablename: TTable; num:
Integer; s1, s2,
        s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13: string);
    s: string;
    f1: Text; // This is not where it is, but this is what it is...
    done: boolean;
    if num = 1 then
        AssignFile(f1, s1);
        while not eof(f1) do
            done := false;
            Readln(f1, s);
            Tablename.FieldByName(s2).Asstring := s;

This code gets executed on Formcreate plus a fair amount more after it
which isn't relevant.  My problem is that the first time through the
while loop, the code works beautifully, does exactly what it is
supposed to do, and sometimes works the entire time when I shut down
delphi 7 and start over.  But on the second pass through, it gets an
EDBEngineError with message 'Key Violation' on the Readln(f1, s);  I
have a paradox 7 table that I am using with an index on the first
field.  Does anybody have any idea what this problem might be?

Another question on the same topic, I cannot put the line f1: Text
local to the procedure, I have to make it global or I get errors that
aren't there (such as missing semicolon...), does anybody know why
this is as well?

Thanks in Advance

PS. I have to write the database contents to a file and read them in
on formcreate because for some reason the database empties itself out
or changes records for no reason once in awhile.