added iostate flags, started working on istream functions (wip)