conditional db file write