explicitly closing the fstreams isn't necessary, also shortening some syntax