add assertion to check if file was written