<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def file2json(self, jsonfile=None):
 """ Convert entire lte file into json like format USAGE: 1: kwsdictstr = file2json() 2: kwsdictstr = file2json(jsonfile = 'somefile') show pretty format with pipeline: | jshon, or | pjson if jsonfile is defined, dump to defined file before returning json string :param jsonfile: filename to dump json strings """

        kwslist = self.detectAllKws()
        kwsdict = {}
        idx = 0
        for kw in sorted(kwslist, key=str.lower):
            # print kw
            idx += 1
            tdict = self.getKwAsDict(kw)
            self.rpn2val(tdict)
            kwsdict.update(tdict)
            if kw not in self.ctrlconf_dict:
                ctrlconf = self.getKwCtrlConf(kw, fmt='dict')
                if ctrlconf is not None:
                    self.ctrlconf_dict.update({kw: ctrlconf})
        kwsdict.update(self.prestrdict)
        ctrlconfdict = {'_epics': self.ctrlconf_dict}  # all epics contrl config in self.ctrlconfdict
        kwsdict.update(ctrlconfdict)
        try:
            with open(os.path.expanduser(jsonfile), 'w') as outfile:
                json.dump(kwsdict, outfile)
        except:
            pass
        return json.dumps(kwsdict)