Factor out writing diphones into a helper function.