1>>> with open('workfile') as f:
2... read_data = f.read()
3
4>>> # We can check that the file has been automatically closed.
5>>> f.closed
6True
7
1f = open('file.txt', 'r')
2for x in f:
3 x = x.lstrip()
4 x = x.rstrip()
5 x = x.title()
6 print x
7