(#2143) - use fs to write a file

to work on windows