def print_totals(hist_dict, filename):
    """


    Parameters
    ----------
    hist_dict : Dictionary
        Histogram dictionary containing number of repeats with certain length.
    filename : String
        Output file name.

    Returns
    -------
    total : Int
        Total number of repeats found.

    """

    keys = list(hist_dict.keys())  # list of repeat lengths

    keys.sort()

    file = open(filename, 'w')

    file.write('rep_num  total\n')

    total = 0  # count repeats

    for rep_num in keys:

        repeats = hist_dict[rep_num]

        line = '{:7}  {}\n'.format(rep_num, repeats)

        file.write(line)

        total += repeats

    # print total number of repeats
    file.write('\nTotal: {}'.format(total))

    file.close()

    return total