Iterating over files with Python

A short block of code to demonstrate how to iterate over files in a directory and do some action with them.

import os
directory = 'the/directory/you/want/to/use'

for filename in os.listdir(directory):
    if filename.endswith(".txt"):
        f = open(filename)
        lines = f.read()
        print (lines[10])
        continue
    else:
    continue

For example,

import gensim
import os
import logging
from gensim.summarization import summarize

logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) 

directory = 'the/directory/you/want/to/use'

for filename in os.listdir(directory):
    if filename.endswith(".txt"):
        f = open(filename, 'r')
        text = f.read()
        print (summarize(text, word_count=20))
        continue
    else:
    continue

Note: something I've found with this is that you need to run the program from the directory defined in the directory variable (which is something I need to fix).