Added separate module for writing index to files.