# The point here is to determine if the trajectory is NVT or NPT. If traj is NPT, the box will change at each iteration and the "header" will appear betwwen every frame
# We try to read the two first frames to figure it out
nAtoms=0
whileTrue:
self._frameSize=self['instance'].tell()
line=self["instance"].readline().strip()
ifnotlineorline.lower().startswith("direct"):
break
self["n_atoms"]+=1
ifnAtoms!=self["n_atoms"]:
raiseXDATCARFileError("The number of atoms (%d) does not match the size of a frame (%d)."%(nAtoms,["n_atoms"]))