<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def read(self):
 """Loads all lines in memory"""

        lines = self.readlines()
        if self.metadata and 'encoding' in self.metadata:
            encoding = self.metadata['encoding']
        else:
            encoding = 'utf-8'
        if sys.version < '3':
            return "\n".join( unicode(line, 'utf-8') if isinstance(line, str) else line for line in lines)
        else:
            return "\n".join( str(line, 'utf-8') if isinstance(line, bytes) else line for line in lines)