Use with ... open() where appropriate instead of just open()

Use with ... open() where appropriate instead of just open(). Also made the names of the opend file handles a bit more consistent.