if it was me, I think I'd just return the number of written bytes here and skip the variable set and break.  But that's a style issue, not a performance one.