add appendMode parameter to put in a file