Can I get a little bit help with this please ? I tried so many times and I still don't know what is the problem. Here is my code:
package com.codegym.task.task18.task1825;

import java.io.*;
import java.util.*;

/*
Building a file

*/

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Set<String> filesList = new TreeSet<String>();
        String fileName;
        while((fileName = reader.readLine()) != null)
        {
            if(fileName.equals("end"))
            {
                break;
            }

            filesList.add(fileName);
        }
        reader.close();



        String outputFile = getOutputFileName(filesList.iterator().next());

        FileOutputStream fos = new FileOutputStream(outputFile);
        for(String s : filesList)
        {
            byte[] buffer = new byte[1000];
            FileInputStream fis = new FileInputStream("D:\\Codegym Files\\" + s);
            while(fis.available() > 0)
            {
                int count = fis.read(buffer);
                fos.write(buffer, 0, count);
                //fos.close();
            }
            fis.close();
        }
        fos.close();

    }

    public static String getOutputFileName(String fileName)
    {
        int index = fileName.lastIndexOf("part");
        String name = fileName.substring(0, index-1);
        return "D:\\Codegym Files\\" + name;
    }
}
Thank you!