fix write return value