public static void main(String[] args) throws IOException {

    if (args.length == 2) {

      File file = new File(args[1]);
      if (file.exists()) {
        file.delete();
      }

      Map<String, Map<String, Long>> invertedIndex = getInvertedIndex(args[0]);
      invertedIndex
          .entrySet()
          .forEach(
              entry -> {
                String line = serializeIndexEntry(entry);
                FileUtils.appendToFile(args[1], line);
              });

      FileUtils.appendToFile(args[1], DOC_LENGTH_SEPARATOR);
      Map<String, Long> documentAndLength = getDocumentAndLength(args[0]);
      documentAndLength
          .entrySet()
          .forEach(
              entry -> {
                String doc = entry.getKey();
                Long length = entry.getValue();
                FileUtils.appendToFile(args[1], String.format("%s=%d", doc, length));
              });

    } else {
      System.out.println("Usage: input_file output_file");
    }
  }