Fixed write size bug