Fixed some I/O errors - setting flags on fs.writeFileSync no longer works, instead using fs.appendFileSync worked