change file read stuff to use an iterator