def save_cont_parameters_to_file(dataset, filename):
    """Save Chebyshev coefficients to file."""
    with open(filename, 'w') as output:
        header = '# Chebyshev Polynomial Coefficients'
        output.write(header + '\n')
        for reg_num, region in enumerate(dataset.regions):
            output.write('# Region %i: \n' % reg_num)
            cheb_parnames = list()
            for parname in dataset.best_fit.keys():
                if 'R%i_cheb' % reg_num in parname:
                    cheb_parnames.append(parname)
            cheb_parnames = sorted(cheb_parnames)
            for i, parname in enumerate(cheb_parnames):
                coeff = dataset.best_fit[parname]
                line = ' p%-2i  =  %.3e    %.3e' % (i, coeff.value, coeff.
                    stderr)
                output.write(line + '\n')
            output.write('\n')
