<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def savecsv(self, filename):
        '''save waypoints to a file in human-readable CSV file'''
        f = open(filename, mode='w')
        headers = ["Seq", "Frame", "Cmd", "P1", "P2", "P3", "P4", "X", "Y", "Z"]
        print(self.csv_line(headers))
        f.write(self.csv_line(headers) + "\n")
        for w in self.wploader.wpoints:
            if getattr(w, 'comment', None):
#                f.write("# %s\n" % w.comment)
                pass
            out_list = [ w.seq,
                         self.pretty_enum_value('MAV_FRAME', w.frame),
                         self.pretty_enum_value('MAV_CMD', w.command),
                         self.pretty_parameter_value(w.param1),
                         self.pretty_parameter_value(w.param2),
                         self.pretty_parameter_value(w.param3),
                         self.pretty_parameter_value(w.param4),
                         self.pretty_parameter_value(w.x),
                         self.pretty_parameter_value(w.y),
                         self.pretty_parameter_value(w.z),
                         ]
            print(self.csv_line(out_list))
            f.write(self.csv_line(out_list) + "\n")
        f.close()