returning -1 for rw on error (makes more sense)