script: Fix busted document fragment appending code