The file is not open sounds about right...
Save the FileSize in a variable when you open the file the first time so then you use that
reference later...
Also, you already set the size of the String at the start so you can use that instead.
If the fileSize fails after you have opened it, it a good chance there is something wrong with the
file, like maybe it does not exist..?
before doing any pascal IO, first do this
InOutRes := 0;
This will clear any pending errors that maybe hanging in limbo .
Previous errors will prevent you from doing any more IO..
So,
InOutRes := 0;
AssignFile(......);
Reset(.....)
if IoResult <> 0 Then Something IS Wrong, like maybe the file does not exist.