I am executing a loop, and in each loop I have to store a parameter in a file. It is like
file = FileNameJoin[{NotebookDirectory[], "info.txt"}];
OpenWrite[file];
Do[out = Prime[i]; WriteString[file, i, "\t", out, "\n"], {i, 1, 10}]
Close[file]
It stores the values perfectly. But when I use Parallelize[], it produce only partial output.
file = FileNameJoin[{NotebookDirectory[], "infop.txt"}];
OpenWrite[file];
Do[out = Prime[i]; WriteString[file, i, "\t", out, "\n"], {i, 1, 10}]
Close[file]
It produces only 4-5 sets out of 10 (They are in random ordering, but that is not a problem). Although when I use Print[], it shows all the sets.
Parallelize[Do[out = Prime[i]; Print[i , "\t", out], {i, 1, 10}]]
The loop I am using for work is pretty big and I may have to check the info.txt file several times to know the status while the code is running. Is there any way to write the data (as the code is running) in a common file while using parallel processing.