check for ndim in write