I'm currently working on a program that I have been assigned that is just getting the word and line count of a sonnet. The first bit of code here works and is the proper output my professor is looking for, even though it includes the first 2 lines of the sonnet.

```
import string

def main():

    ifName = input("What file would you like to analyze? ")
    ofName = input("What file should the results be written to? ")

    infile = open(ifName, "r")
    outfile = open(ofName, "w")

    lineCount = 0
    wordCount = 0

    for line in infile:
        lineCount +=1
        wordLine = line.split()
        L = len(wordLine)
        wordCount += L

    print("The file", ifName, "had:", file= outfile)
    print("words =", wordCount, file= outfile)
    print("lines =", lineCount, file= outfile)
    print("The results have been printed to:", outfile)

    infile.close
    outfile.close

main()

```

However, the next part of the assignment is to get the same results using a second function, "countNum" with the parameter of "line". So countNum(line).

Here is the code I have been messing around with to see if I can get it to work.

```
import string

def countNum(line):
    wordCount = 0
    wordLine = line.split()
    L = len(wordLine)
    wordCount +=L
    print(wordCount)

def main():

    ifName = input("What file would you like to analyze? ")
    ofName = input("What file should the results be written to? ")

    infile = open(ifName, "r")
    outfile = open(ofName, "w")

    lineCount = 0
    wordCount = 0

    for line in infile:
        lineCount +=1
        wordTotal += countNum(line)
        ##wordLine = line.split()
        ##L = len(wordLine)
        ##wordCount += L

  ##  print("The file", ifName, "had:", file= outfile)
  ##  print("words =", wordCount, file= outfile)
  ##  print("lines =", lineCount, file= outfile)
  ##  print("The results have been printed to:", outfile)

    infile.close
    outfile.close

main()

```

If you were wondering, this is the sonnet.txt file:

```

Shakespeare’s Sonnet 18

Shall I compare thee to a summer's day?
Thou art more lovely and more temperate:
Rough winds do shake the darling buds of May,
And summer's lease hath all too short a date:
Sometime too hot the eye of heaven shines,
And often is his gold complexion dimm'd;
And every fair from fair sometime declines,
By chance or nature's changing course untrimm'd;
But thy eternal summer shall not fade
Nor lose possession of that fair thou owest;
Nor shall Death brag thou wander'st in his shade,
When in eternal lines to time thou growest:
So long as men can breathe or eyes can see,
So long lives this, and this gives life to thee.

```