function to write a string to a file

copy the code of file handling / write to file

click here to select all the code