I am getting this error "The program is still running! Do you wan to kill it?" from the python IDE when I run the following code. Any ideas why this is happening?

#!/usr/bin/python

import sys

########################################################################
# prints program usage
########################################################################
def printUsage():
    print "** Print part of Bible **"
    print "Examples of usage:"
    print "lookup book chapter"
    print "lookup book chapter:verse"
    print "lookup book chapter:verse1-verse2"


########################################################################
# parse command line
########################################################################
def parseCommandLine():
    book = ""
    chapter = -1
    verse1 = -1
    verse2 = -1

    # number of agruments should be 2, so n should be equal to 3
    n = len(sys.argv)  

    if (n!=3):
        #printUsage()
        return (book, chapter, verse1, verse2)

    # book should have at least three letters
    book = sys.argv[1];


    if len(book)<3:
        print "Error: Incorrect book name"
        #printUsage()
        return (book, chapter, verse1, verse2)

    # keep only first three letters of the book and convert them to lower case
    book = sys.argv[1][:3].lower()

    # split second parameter sys.argv[2] by symbol ":"
    s = sys.argv[2].split(":");
    chapter = s[0]

    # if it does not contain ":", 
    # then keep verse1 and verse2 equal to -1 and finish 
    if (len(s)==1):
        return (book, chapter, verse1, verse2)

    # now try to split s[1] with "-", so checkif it has the form 
    # either "verse" or "verse1-verse2"
    v = s[1].split("-")
    verse1 = int(v[0])

    if (len(v)==1):
        return (book, chapter, verse1, verse2)

    verse2 = int(v[1])

    return (book, chapter, verse1, verse2)



########################################################################
#  Prints formatted line of one element of bible
########################################################################
def printFormattedLine(v):
    """
    Prints formatted line of lengt 100
    """

    verseText = v["verseText"]

    # reference
    ref = v["book"] + " " + v["chapter"] + ":" + v["verse"] + "   "
    # length of the output line
    totalLen = 100
    # length of remained stri   ng
    verseStrLen = totalLen - len(ref)

    # spline the line into words
    words = verseText.split(" ")

    firstLine = 1  # this variable shows that the line is first
    curLine = ""   # current line
    for w in words:
        if len(curLine) + 1 + len(w) > verseStrLen:
            # the line is completed and we print it
            if firstLine == 1:
                # in the first line we print reference
                curLine = ref + " " * ( totalLen - len(ref) - len(curLine) ) + curLine
            else:
                # in all other lines print spaces
                curLine = " " * ( totalLen - len(curLine) ) + curLine
            print curLine
            curLine = ""    # reset current line
            firstLine = 0   # all other lines are not "first"
        else:
            # the line is not exceedes totlLength(100) symbols,
            # so we add a new word
            curLine = curLine + " " + w

    # after the loop we should print remained string
    if len(curLine)>0:
        if firstLine == 1:
            curLine = ref + " " * ( totalLen - len(ref) - len(curLine) ) + curLine
        else:
            curLine = " " * ( totalLen - len(curLine) ) + curLine
    print curLine
    print

########################################################################
# Print part of the bible
########################################################################
def printPart(book, chapter, verse1, verse2):
    """
    Print the verses from verse1 to verse2 of the corresponding
    chapter of the book 

    If verse1<0, then print all chapter

    If verse1>0 and verse2<0, then prints only verse1

    If verse1>0 and verse2>0, then prints all verses from verse1 to verse2
    """

    if (verse1>0) and (verse2<0):
        verse2 = verse1

    if (verse1>0) and (verse2>0):
        for v in bible:
            verse = int(v["verse"])
            if (v["book"]==book) and (v["chapter"]==chapter) and (verse1 <= verse) and (verse <= verse2):
                printFormattedLine(v)
    else:  # now verse2<0, so we print all the chapter            
        for v in bible:
            if (v["book"]==book) and (v["chapter"]==chapter):
                verse = int(v["verse"])
                printFormattedLine(v)



##############  MAIN PROGRAM  ##############

# parse command line
(book, chapter, verse1, verse2) = parseCommandLine()

if len(book)==0:
    printUsage()
    exit(1)


# read file into a dictionary
f = open("kjv.txt", "r")
bible = []
# read lines from the file
# each line has the following structure:
# lineNumber | book chapter:verse | verseText
for line in f:
    # split line into "lineNumber", "book chapter:verse", and "verseText"
    s = line.strip().split(" | ")
    lineNo = s[0]        # save line number
    vt = s[2]            # save verseText

    a = s[1].split()     # split "book chapter:verse" into "book" and "chapter:verse"
    bk = a[0]            # save book
    b = a[1].split(":")  # split "chapter:versus" into "chapter" and "verse" 
    ch = b[0]            # save chapter
    vs = b[1]            # save verse

    v = {"lineNo":lineNo, "book":bk, "chapter":ch, "verse":vs, "verseText":vt}       
    bible.append(v);


# print the required part of the book
printPart(book, chapter, verse1, verse2)

If you click the X while it's still computing or waiting for input or doing whatever, it does that because it takes forever

This question has already been answered. Start a new discussion instead.