add write_if option
Merge pull request #1 from timsly/write-if

Add write_if option