Open (and close) a file with the with statement.

with open(filename,'r') as fh
    all_lines = fh.readlines

More here