changed command structure so xoutfile is only loaded if needed
changed command structure so we automatically append to outfile if it is the same file as onward. Otherwise we open outfile for writing