Change logic to be able to write into separate files.