check return from write