fixed the check the success of the write