from sys import argv

script, file_name = argv


def input_and_calculate_one_line():
    txt_result = ''
    number = input("> ")
    if number == 'q':
        txt_result = ''
        return txt_result
    
    sp_number = number.split(' ')
    for i in range(len(sp_number) - 1):
        txt_result = txt_result + sp_number[i] + ' + '
    
    sp_number = list(map(int, sp_number))
    result = sum(sp_number)
    txt_result = txt_result + str(sp_number[-1]) + ' = ' + str(result) + '\n'
    return txt_result


def editor():
    txt = open(file_name, 'w')
    while True:
        output = input_and_calculate_one_line()
        if output == '':
            txt.close()
            exit(0)
        else:
            print(output)
            txt.write(output)


editor()
