public static String split(String filePath, int begin, int end) throws FileNotFoundException, IOException {
        String prefix;
        try (Scanner scan = new Scanner(new FileReader(filePath))) {
            if (! new File(tmp).exists())
                new File(tmp).mkdir();
            prefix = UUID.randomUUID().toString();
            FileWriter files[] = new FileWriter[3];
            for (int i = 0; i < 3; i++)
                files[i] = new FileWriter(tmp + prefix + "-" + Integer.toString(i + 1) + extension_tmp);
            int actual = 0;
            int lines = lines(filePath);
            String text;
            while (scan.hasNextLine()) {
                text = scan.nextLine();
                // add newline only if this is not the end of the part file
                if (actual != begin - 1 && actual != end && actual != lines - 1)
                    text += separator;

                // place text in the right part
                if (actual < begin)
                    files[0].append(text);
                else if (actual > end)
                    files[2].append(text);
                else
                    files[1].append(text);

                actual++;
            }
            for (int i = 0; i < 3; i++)
                files[i].close();
        }

        // return the temporary files’ prefix
        return prefix;
    }