Thanks - I realised the main problem I had beofre was along those lines - it was working, but I wasn't appending. Thus, it was outputting to the file, but as I was leaving a few blank lines at the end (intending to run the file on a regular basis via task scheduler), it was writing the file correctly, the overwriting it with the blank lines. Duh...