Use dolfinx.io.VTXWriter instead of xdmffile if you are not using isoparametric elements.
dolfinx.io.VTXWriter