Write to correct xmp file when manually writing

this was broken for duplicates

(cherry picked from commit 7bc0fd4d7849e843a8d1524a7d7949415d44307b)