write failed doc IDs to a file and enable reading doc IDs from a file

This is useful if you want to be able to retry failed docs.