Fixed index getting corrupted when adding to existing index.

A small logic bug caused the previous terms file to be overwritten
instead of added to.