implemente writing indexes to files refs #123