[ fix ] added handling of closed and error situations for reading and writing in posix io layer