While appendFileSync is synchronous, it's executed inside an asynchronous promise chain that's not properly awaited. This means your subsequent file read operations (fs.readFileSync('key_${step}.txt')) might execute before the files are actually written.