Thank you Nicolas for fixing it so quickly! Unfortunately now that I can test it I see a problem with the fix:
When archiving an "ordinary" entry with 'n' empty lines after it there will be zero empty lines after it (or before it) in the Datetree. However, those archived in the order described by my bug report gets n + 1 empty lines after them.