fix double write to w