Can I ask why you are using the system call from C to write to a file in the first place? You do realize that there exists a slew of API calls that are much more efficient than creating a new process to write a single line of text to a file.
Code:
FILE *fp;
fp = fopen("a.xml", "wt");
fprintf(fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
fclose(fp);
Would be
much better and you can even continuing writing XML to file instead of closing it.