change from system output to file write