Get information on state of IOStream

Maybe you could use while !eof(io)?
See one example here.