title: List all Index in a string that satisfies a certain string
body: <p>I am trying to use python to read a text file and search a certain string in the file as below</p>
  
  <pre><code>with open("controlDict","r") as myfile:
      file=myfile.read()
  
  IndexFirst=file.find('fields')
  </code></pre>
  
  <p>However, I found out that it only gives me the first index of 'fields' in the file but I need to find all the indexes where 'fields' appears on the line.</p>
  
  <p>I did some research online and tried below</p>
  
  <pre><code>Index=[i for i, val in enumerate(file) if val=='fields']
  </code></pre>
  
  <p>but it does not work and returns an empty list. </p>
  
  <p>I am not sure why, anyone has any suggestions?</p>