Added "with open()" to main loop

Replaced argparse file-opening functionality using with open() loops in
order to more correcty handle file open/write/close and avoid error
states which could lock files open.