fixed small bug in write attributes