title: Python ValueError: I/O operation on closed file. when returning a dict from a DictReader
body: <p>I am getting ValueError: I/O operation on closed file when I return a dict from a csv file.  How should I do this? </p>
  
  <pre><code>def main():
      groups = get_groups()
      for line in groups:
          print(line)
  
  def get_groups():
      file1 = 'groups.csv'
      with open(file1, 'r') as file:
          groups = csv.DictReader(file)
      return groups
  </code></pre>