Track query and file I/O failures separately, so that they canbe handled appropriately and repeat writes to the output file can be avoided.  Also increased the maximum number of re-enqueues to 4.