Write offsets to datasets only if message is processed

Move it closer to where it is used (i.e. before `for`).