new function added - write. It is called, to write a result into a file.