modified CSV write to rectify trailing comma