Added logic to correctly generate the index to output dir.