<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def convertforinput(self,filepath, metadata=None):
 """Convert from target format into one of the source formats. Relevant if converters are used in InputTemplates. Metadata already is metadata for the to-be-generated file."""

        super(CharEncodingConverter,self).convertforinput(filepath, metadata)

        shutil.copy(filepath, filepath + '.convertsource')

        try:
            fsource = io.open(filepath + '.convertsource','r',encoding=self.charset)
            ftarget = io.open(filepath,'w',encoding=metadata['encoding'])
            for line in fsource:
                ftarget.write(line + "\n")
            success = True
        except:
            ftarget.close()
            fsource.fclose()
            success = False
        finally:
            os.unlink(filepath + '.convertsource')

        return success