Added writing output directly to files