Add better error trapping when trying to write to an FSTD file.

E.g., if the file doesn't exist or is damaged.

Otherwise, we get a segmentation fault.