You should test the value of the built-in function ioerror after every write operation to see if the operation was successful. The value returned by ioerror is a boolean value: if the operation was successful (there was no failure), the value is false; if it failed, the value is true. For example:
response to Finished
write append Chapter1 to file Report
if ioerror
then change to program Reformat
end if
The textual region Chapter1 is appended to the text file Report when Finished is selected. Then ioerror is tested. If the write operation was not successful, ESL changes to the program Reformat.