def ProcessData():
    try:
        f_in = open(args.ctm_edits_in)
    except:
        sys.exit('modify_ctm_edits.py: error opening ctm-edits input file {0}'.format(args.ctm_edits_in))
    try:
        f_out = open(args.ctm_edits_out, 'w')
    except:
        sys.exit('modify_ctm_edits.py: error opening ctm-edits output file {0}'.format(args.ctm_edits_out))
    num_lines_processed = 0
    first_line = f_in.readline()
    if (first_line == ''):
        sys.exit('modify_ctm_edits.py: empty input')
    split_pending_line = first_line.split()
    if (len(split_pending_line) == 0):
        sys.exit(('modify_ctm_edits.py: bad input line ' + first_line))
    cur_utterance = split_pending_line[0]
    split_lines_of_cur_utterance = []
    while True:
        if ((len(split_pending_line) == 0) or (split_pending_line[0] != cur_utterance)):
            split_lines_of_cur_utterance = ProcessUtterance(split_lines_of_cur_utterance)
            for split_line in split_lines_of_cur_utterance:
                print(' '.join(split_line), file=f_out)
            split_lines_of_cur_utterance = []
            if (len(split_pending_line) == 0):
                break
            else:
                cur_utterance = split_pending_line[0]
        split_lines_of_cur_utterance.append(split_pending_line)
        next_line = f_in.readline()
        split_pending_line = next_line.split()
        if (len(split_pending_line) == 0):
            if (next_line != ''):
                sys.exit('modify_ctm_edits.py: got an empty or whitespace input line')
    try:
        f_out.close()
    except:
        sys.exit('modify_ctm_edits.py: error closing ctm-edits output (broken pipe or full disk?)')
def ProcessData():
    try:
        f_in = open(args.ctm_edits_in)
    except:
        sys.exit('modify_ctm_edits.py: error opening ctm-edits input file {0}'.format(args.ctm_edits_in))
    try:
        f_out = open(args.ctm_edits_out, 'w')
    except:
        sys.exit('modify_ctm_edits.py: error opening ctm-edits output file {0}'.format(args.ctm_edits_out))
    num_lines_processed = 0
    first_line = f_in.readline()
    if (first_line == ):
        sys.exit('modify_ctm_edits.py: empty input')
    split_pending_line = first_line.split()
    if (len(split_pending_line) == 0):
        sys.exit(('modify_ctm_edits.py: bad input line ' + first_line))
    cur_utterance = split_pending_line[0]
    split_lines_of_cur_utterance = []
    while True:
        if ((len(split_pending_line) == 0) or (split_pending_line[0] != cur_utterance)):
            split_lines_of_cur_utterance = ProcessUtterance(split_lines_of_cur_utterance)
            for split_line in split_lines_of_cur_utterance:
                print(' '.join(split_line), file=f_out)
            split_lines_of_cur_utterance = []
            if (len(split_pending_line) == 0):
                break
            else:
                cur_utterance = split_pending_line[0]
        split_lines_of_cur_utterance.append(split_pending_line)
        next_line = f_in.readline()
        split_pending_line = next_line.split()
        if (len(split_pending_line) == 0):
            if (next_line != ):
                sys.exit('modify_ctm_edits.py: got an empty or whitespace input line')
    try:
        f_out.close()
    except:
        sys.exit('modify_ctm_edits.py: error closing ctm-edits output (broken pipe or full disk?)')