# Tutorial 3 - Problem 2
#
# Here is a Python program that reads words_35.txt
# and prints only the words with more than 20 characters
# (not counting whitespace and newline character).
# One word per output line.
#
# Anne Lavergne
# Dec. 2015

# Either ask user for a filename (and perhaps also a path)
# or
# set your filename variables once at the top of your program
# Why?
inputFile = 'words.txt'

# Opening a file for reading
fileRead = open(inputFile, 'r') # or open(inputFile)

# Reading using a loop
for line in fileRead:     # for each line in the file, line is a string
    word = line.strip()   # strip whitespaces and newline character
    if len(word) > 20:    # if a word has more than 20 characters
        print(word)       # print it on its own line 

fileRead.close( )


# Answer: 3 words printed on the computer monitor screen:
# counterdemonstrations
# hyperaggressivenesses
# microminiaturizations