<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_file(self, filename, **kwargs):
 """ dump a representation of the nparray object to a json-formatted file. The nparray object should then be able to be fully restored via nparray.from_file @parameter str filename: path to the file to be created (will overwrite if already exists) @rtype: str @returns: the filename """

        f = open(filename, 'w')
        f.write(self.to_json(**kwargs))
        f.close()
        return filename