let fs = require('fs');

let files = [
  "inicio.html",
  "tabla_de_contenido.html",
  "capitulo_00.html",
  "capitulo_01.html",
  "capitulo_02.html",
  "capitulo_03.html",
  "capitulo_04.html",
  "capitulo_05.html",
  "capitulo_06.html",
  "capitulo_07.html",
  "final.html",
];

let output_file = "index.html";
let output_content = "";

files.forEach(file => {
  try {
    let content = fs.readFileSync(file, "utf8");
    output_content += content + "\n\n";
  }
  catch(e) {
    console.log(`El archivo <<${file}>> no existe.`)
  }
});

fs.writeFileSync(output_file, output_content, "utf8");