Use file object iteration, introduced in Python 2.3
Simplify some operations on sequences

* Use extend() rather than assigning to end slice
* startswith() and endswith() introduced in Python 2.0
* No need to manually limit slice to size of sequence