<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _next_ontology(self):
 """Dynamically retrieves the next ontology in the list"""

        currentfile = self.current['file']
        try:
            idx = self.all_ontologies.index(currentfile)
            return self.all_ontologies[idx+1]
        except:
            return self.all_ontologies[0]