How to avoid YAML lib to add new blank line after a variable with null value

I have a node script to modify content of docker compose file (yaml file). I used yaml lib to parse from file:

const fs = require('fs')
const yaml = require('yaml')

const compose = yaml.parseDocument(fs.readFileSync(file, 'utf-8'), {merge: true})

... do something to modify content...

fs.writeFileSync(file, yaml.stringify(compose, {
  nullStr: '',
  simpleKeys: true,
  lineWidth: 0
}))

after I write the updated content back to the file, there is no problem except it added new blank line after each null value (attached file)

enter image description here

I don’t know the reason why it do it (maybe the variable with null value is the reason). it’s default behaviour? How I can avoid it?