Improved WriteToFile Function

I have fixed some unnecessary if
Also added a cout to the user saying that the output file was written
and the name of it
Merge remote-tracking branch 'origin/master' into mnap