Added the write file functionnality
Fixed the wrong file path for the beforetext and aftertext files