changed bagOfWords write file