Hello, I was able to solve this task, but still have a few questions. 1. I don't understand, why bufferedwriter doesn't write first line. Input is: 1 2 3 exit In my file I can find: 2 3 exit 2. Where shoud I close the reader? Can anybody please help me? Thank you :)
BufferedReader reader = null;
BufferedWriter bufferedWriter = null;
FileWriter fileWriter = null;

try {
    reader = new BufferedReader(new InputStreamReader(System.in));
    String datei = reader.readLine();

    fileWriter = new FileWriter(datei);
    bufferedWriter = new BufferedWriter(fileWriter);

    while (true) {

        String zahl = reader.readLine();

        bufferedWriter.write(zahl);
        bufferedWriter.newLine();

        if (zahl.equals("exit")) {
           // reader.close();
            break;
        }
    }

} catch (IOException e) {
    e.printStackTrace();
} finally {

    bufferedWriter.close();
    fileWriter.close();
}