Added error handling and resumption from arbitrary offset