Did you know ... Search Documentation:
Predicate recover_db/6
 recover_db(+Error, +In, +File, +Pos, -Action, -End) is det[private]
Called if reading the term that starts at Pos raised Error. If the syntax error is at the end of the file we assume the last write only partially made it to disk, e.g., because the disk was full or the process was killed. In that case we print a warning and truncate the file to Pos, i.e., just after the last valid term. Anything else is re-raised.

Note that we do not repair a file from which not a single term could be read (Pos is 0). Such a file is most likely not a persistent database at all and we do not want to destroy it.