Fixing a bug in node file writing logic