Don't.
The example you give is not a good candidate for parallel processing: the output needs to be in order in a single file: when you start multi threading 1000 operations, you can't control the order, and each one has to "wait it's turn" to access the file - or all bar one of those running at the same time will find the file in use and fail to write.
In addition, remember that each thread needs an available core to actually run - so unless you have 1000 cores available, multithreading a task like this will make the whole operation take longer than it would in a single thread, as the task setup and switching overhead will outweigh the actual processing by orders of magnitude!
I appreciate that this isn't actually what you are trying to do in your project, but many of the same problems are going to occur if your "real world" task is in any way similar (as it should be to be a useful description here).
I'd stop and think about what you are doing and why you need to parallelise it before you go any further!