Write global/local ngrams into csv file