Hi Silvia,
it is good practice to close a file before reopening it - there is a CloseFile() missing in your OnClick handler for Button1. There seems to be no further problem with your code, means it performs as intended on my machine. Can you point out the very line of code that throws the
exception?
BTW: Modern times file i/o is done with filestreams. You might want to read about it in the Online Help. You will transfer your knowledge about files quite easily. Typed and untyped files are ment to deal with legacy code.
kind regards
marabu