Can you use an absolute path when you open the file, like "/jevois/targetData.txt"?
It might be that for some strange reason you do not always end up being in the module's directory as you should be (maybe something funny going on during instantiation of a python module, the constructor may be called before we change directory to the module's directory). The /jevois partition should be writable.
Or, in the inventor console, try
shell dmesg
and look for messages that would signal some disk error and re-mounting read-only. Or try
shell touch /jevois/hello
and then
shell ls /jevois
and see if you get errors and whether the file was created.
If that does not help, we have had strange situations also (but hard to reproduce) when trying to save python code to SD repeatedly and across multiple days. I think it might have to do with date and pycache. And maybe a broken pycache triggers the remount to read-only. So I would recommend the following: after JeVois boots up, fire up the inventor and go to the System tab and set the date/time on the camera to that of your host. Then you should have no problem editing, etc. My guess about this is that since by default jevois starts on Jan 1, 1970 (since there is no battery for the clock), depending on when you edit and try to save, you may end up with saving the source python file earlier than you did last time you booted up JeVois, and so now you end up with the compiled python code in pycache being in the future compared to the time at which you save your source python file. That may upset python.