In a script context, you should be able to access the file via the dw.io
namespace classes. You can see the available classes in the documentation for the dw.io namespace.
Note that you cannot access the filesystem from the storefront context. Therefore whatever you want to do with that file must be done within the context of a Job or possibly an OCAPI hook. (I'm not sure on the hook) There is a group of quotas that prevent this from occurring. The list is found here: dw.io quotas. Note that all of the I/O APIs have a Storefront limit of 0
.
I'd recommend you check out the FileHelper.js from the job-components library for examples and/or an abstraction layer for you to use. Then I also recommend examining how they built their job steps so you can build a custom one for your needs as it's likely you'll need to build a job of some kind to do what you want to do. See the job steps documentation for more info on how to work with jobs and job steps.
You may also find that the job-components library already offers you what you need to do. I'm not sure because your question was pretty vague.