Added index writing to file and computing tf, idfs