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

/*
Introducing properties

*/

public class Solution {
    public static Map<String, String> properties = new HashMap<>();

    public void fillInPropertiesMap() throws Exception {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String fileName = bufferedReader.readLine();
        bufferedReader.close();
        try(FileInputStream inputStream = new FileInputStream(fileName)){
            load(inputStream);
        }
    }

    public void save(OutputStream outputStream) throws Exception {
        Properties properties1 = new Properties();
        for(Map.Entry<String,String> entry: properties.entrySet()){
            properties1.setProperty(entry.getKey(), entry.getValue());
        }
        properties1.store(outputStream,"");
    }

    public void load(InputStream inputStream) throws Exception {
        Properties properties1 = new Properties();
        properties1.load(inputStream);
        Set<String> propertyNames = properties1.stringPropertyNames();
        for(String s: propertyNames){
            properties.put(s,properties1.getProperty(s));
        }
    }

    public static void main(String[] args) throws Exception {
        Solution solution = new Solution();
        solution.fillInPropertiesMap();
        BufferedReader bufferedReader1 = new BufferedReader(new InputStreamReader(System.in));
        String fileName = bufferedReader1.readLine();
        try(FileOutputStream outputStream = new FileOutputStream(fileName)){
            solution.save(outputStream);
        }

    }
}
I've passed the task with the above code minus the code in the main method. That was just for me to try it out on my machine. But why do I get the following error after I pass in the first filename and after solution.fillInPropertiesMap(); finished it's work. Instead of getting the possibility to put in a second file name I get this: Exception in thread "main" java.io.IOException: Stream closed at java.io.BufferedInputStream.getBufIfOpen(BufferedInputStream.java:170) at java.io.BufferedInputStream.read(BufferedInputStream.java:336) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) at java.io.InputStreamReader.read(InputStreamReader.java:184) at java.io.BufferedReader.fill(BufferedReader.java:161) at java.io.BufferedReader.readLine(BufferedReader.java:324) at java.io.BufferedReader.readLine(BufferedReader.java:389) at com.codegym.task.task20.task2003.Solution.main(Solution.java:44) where line 44 is String fileName = bufferedReader1.readLine(); in my code. But as soon as I delete bufferedReader.close(); in line 15 everything works fine. But I opened a new stream. who is my "stream closed" apparently.