Update the Remind command with the uid in the file with the new iCalendar

def replace_vobject(self, uid, ical, filename=None):
        """Update the Remind command with the uid in the file with the new iCalendar"""
        if not filename:
            filename = self._filename
        elif filename not in self._reminders:
            return

        uid = uid.split('@')[0]

        with self._lock:
            rem = open(filename).readlines()
            for (index, line) in enumerate(rem):
                if uid == md5(line[:-1].encode('utf-8')).hexdigest():
                    rem[index] = self.to_reminders(ical)
                    new_uid = self._get_uid(rem[index])
                    open(filename, 'w').writelines(rem)
                    return new_uid