Set correct file modes
Ref files are to be written 644.
Currently withHandle creates all files 444.