Modified write and writeSync to accept replacer and space argument