invoke function writes output to file