def METHOD_NAME(filename, name, waypoints):
    maxdist = 250.
    if not filename:
        raise ValueError("filename to save flight track cannot be None")
    max_loc_len, max_com_len = len("Location"), len("Comments")
    for wp in waypoints:
        if len(str(wp.location)) > max_loc_len:
            max_loc_len = len(str(wp.location))
        if len(str(wp.comments)) > max_com_len:
            max_com_len = len(str(wp.comments))
    with codecs.open(filename, "w", encoding="utf-8") as out_file:
        out_file.write(u"# Do not modify if you plan to import this file again!\n")
        out_file.write(
            f"# This file contains NAVAID-DME names for points less than {maxdist:.0f} "
            "nm distance from closest NAVAID point\n")
        out_file.write(f"Track name: {name:}\n")
        line = u"{0:5d}  {1:{2}} {3:11} {4:4.0f}° {5:02.0f}'  {6:4.0f}° {7:02.0f}' {8:7.1f} {9:7.1f}  {10:8.1f}" \
               u"  {11:8.1f}  {12:{13}}\n"
        header = f"Index  {'Location':{max_loc_len}} NAVAID-DME    Lat      Lon      FL (hft) P (hPa)  " \
                 f"Leg (km) Cum. (km)  {'Comments':{max_com_len}}\n"
        out_file.write(header)
        for i, wp in enumerate(waypoints):
            # ToDo check str(str( .. ) and may be use csv write
            loc = str(wp.location)
            lat = wp.lat
            lon = wp.lon
            # transform to degrees and minutes
            latdeg = np.floor(lat)
            if lat < 0:
                latdeg = - np.floor(-lat)
            latmin = abs(round((lat - latdeg) * 60.))
            londeg = np.floor(lon)
            if lon < 0:
                londeg = - np.floor(-lon)
            lonmin = abs(round((lon - londeg) * 60.))
            nav = radial_dme(lat, lon, maxdist=maxdist)
            lvl = wp.flightlevel
            pre = wp.pressure / 100.
            leg = wp.distance_to_prev
            cum = wp.distance_total
            com = str(wp.comments)
            out_file.write(line.format(i, loc, max_loc_len, nav, latdeg, latmin,
                                       londeg, lonmin, lvl, pre, leg, cum, com,
                                       max_com_len))