<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def flush(self):
 """Ensure contents are written to file."""

        for name in self.item_names:
            item = self[name]
            item.flush()
        self.file.flush()