diff --git a/dr.botzo.py b/dr.botzo.py index 099e943..36c176e 100755 --- a/dr.botzo.py +++ b/dr.botzo.py @@ -544,8 +544,8 @@ class FactFile(Module): # open file if os.path.isfile(filename): # http://www.regexprn.com/2008/11/read-random-line-in-large-file-in.html - file = open(filename, 'r') - facts = file.readlines() + with open(filename, 'r') as file: + facts = file.readlines() to_print = facts[random.randint(0, len(facts))] # return text