A little clarification please. You indicate the script now gets stuck in JMP 19, further down you indicate, in JMP 19 the script was working as is...? I'm assuming you mean it hangs in JMP 19 but was working in 18? Always helpful to have the full version numbers since we do make security and bug fix releases such as 19.0.1.
What is supposed to happen, is that the file would be saved to the same directory as the JSL script. Running the JSL script would set the current working directory to the location of the jsl script, and without additional path components on the Python open() would default to saving in the same directory as the JSL. If your JSL isn't pulling further JSL files as includes, you could even use Python commands to change the current working directory.
On the Python side of things you can easily specify the full path to the file, including use of special directories.
import jmp
import os
...
# using os.path.join() makes path portable on macOS and Windows
on_desktop = os.path.join( jmp.DESKTOP, 'results.json')
with open( on_desktop, 'w+' as f:
f.write( str(response.primary_results[0]))
..