switched file i/o to with statements