Thread safety; Optional output to file specified by pathname