The with construct makes sure the file is closed afterwards.
with open( fileName) as f: lines = f.read().splitlines()