add option to specify whether to write given query, list of wids, or last indexed
strip wid before writing
update docstring