add asserts to check temporary files has actually been written