<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convert(self, path, version, target = None):
 """Converts the specified file using the relevant template. :arg path: the full path to the file to convert. :arg version: the new version of the file. :arg target: the optional path to save the file under. If not specified, the file is saved based on the template file name. """

        #Get the template and values out of the XML input file and
        #write them in the format of the keywordless file.
        values, template = self.parse(path)
        lines = template.write(values, version)

        #Finally, write the lines to the correct path.
        if target is None:
            target = os.path.join(os.path.dirname(path), template.name)

        with open(os.path.expanduser(target), 'w') as f:
            f.write("\n".join(lines))