states.file.replace(append/prepend_if_not_found)

Feature just merged for modules.
Straight-forward patch for state file.

Note: not tested yet, but it *looks* simple enough.