The code below describes a Java situation. I used some psudocode in the getRuntime().exec function; but, the main point is that a new file is created.
Although the second line causes an error the first time it is run I can see the new file has been created. Also, the 2nd time I run it, it works; I mean to say the 2nd time it is run, it can read the file created on the previous run. So, the best I can figure is that the 2nd line needs to wait until the new file is created (~1,000 lines of text).
Runtime.getRuntime().exec(new String[] {"Do something that writes a new file", "c:/"+newFileName+".xml"});
...
File fileToParse = new File("c:/"+newFileName+".xml");
Fileto create the file on your system? That way you know it is done when the method returns. How about:File#createNewFile()