add monkey patch to write file only after commit

This ensure a file is never created on filesystem while transaction will restart.

This former behavior was creating multiple times the same file.