I have a txt file. How can I take dictionary key values and print the line of text they appear in?
<p>I have a txt file.  I have written code that finds the unique words and the number of times each word appears in that file.  I now need to figure out how to print the lines that those words apear in as well.  How can I go about doing this? </p>

<blockquote>
  <p>Here is a sample output: 
  Analyze what file: itsy_bitsy_spider.txt<br>
  Concordance for file itsy_bitsy_spider.txt
  itsy : Total Count: 2
  Line:1: The ITSY Bitsy spider crawled up the water spout
  Line:4: and the ITSY Bitsy spider went up the spout again</p>
</blockquote>

<pre><code>#this function will get just the unique words without the stop words. 
def openFiles(openFile):

    for i in openFile:
        i = i.strip()
        linelist.append(i)
        b = i.lower()
        thislist = b.split()
        for a in thislist:
            if a in stopwords:
                continue
            else:
                wordlist.append(a)
    #print wordlist




#this dictionary is used to count the number of times each stop 
countdict = {}
def countWords(this_list):
    for word in this_list:
        depunct = word.strip(punctuation)
    if depunct in countdict:
        countdict[depunct] += 1
    else:
        countdict[depunct] = 1
</code></pre>
