Corrected issue #1, reformatted record creation, opening files using "with"