Create a reusable function to generate vocab file.