title: define a function to search for a specific word in a text file and print total lines
body: <p>I need help with my code. I am trying to define a function that will search for a specific word in a text file and then print out all the lines with the give word and the total of times the word appears in the text file. </p>
  
  <pre><code>def read_words(fname):
      fin = open(fname)
      es_count = 0
      for w in fin:
          word=w
          if " " in word:
              es_count = es_count + 1
              print(word)
  </code></pre>
  
  <p>The output needs to show the words and the total count.
  For example: words in text file that have OG in them.</p>
  
  <p>correct output needed:</p>
  
  <pre><code>dog
  fog
  jog
  hog
  the total number of words: 4
  </code></pre>