I think you're falling into the mindset a lot of people do when trying to return a file.My first bit of advice is to not over think it (yeah, easier said then done, I know).If you have a tool in Desktop that works...ie, a python script tool that outputs a file, you have a parameter that either is output required or a derived output - either way, its of type FILE.You run this tool in Desktop, open the results window, expand that successful result and there will be the output file you can double click. If you're output a txt file, double clicking it should open it in notepad (or whatever you PC opens .txt files with).Now moving to Server, dont over think it assuming you need to return a URL or worry about virtual directories. The GP/Server framework handles all of this. The only thing that changes in terms of GP Server and file output is the client consuming the service. If your client happens to be ArcMap, run the tool from your server connection. Expand the result in the Results window and double click the result. Exact same experience...ArcMap as a client handled getting the file down from the Server and helped you open it.If your client is the Services Directory (REST Endpoint), a successful result will return a link you can click to download the file.If your client is a web app, you do need to write some code to handle getting the result and saving it (well telling the browser to popup a box and save it).Apologies if I'm off base and you understand this bit - if your question is "how do I write the python code to output a file", well it should be handled as well. In short, your code could be this simple (assuming input parameter of string and derived output parameter of file)import arcpy import os getInputTxt = arcpy.GetParameterAsText(0) txtFile = os.path.join(arcpy.env.scratchFolder, "myTxt.txt") f = open(txtFile, 'w') f.writelines(getInputTxt) f.close arcpy.SetParameterAsText(1, txtFile)