modified driver to write to file