<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def replace(self, pattern, replacement):
 """ Replace all instances of a pattern with a replacement. Args: pattern (str):
 Pattern to replace replacement (str):
 Text to insert """

        for i, line in enumerate(self):
            if pattern in line:
                self[i] = line.replace(pattern, replacement)