package com.codegym.task.task13.task1319;

import java.io.*;

/*
Writing to a file from the console

*/

public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String fileName = reader.readLine();
        File file = new File("c:/progs/files/CodeGym/" + fileName);

        FileWriter fw = new FileWriter(file);
        BufferedWriter bw = new BufferedWriter(fw);

        while (true) {
            String s = reader.readLine();

            if (!s.equals("exit")) {
                bw.write(s + "\n");
                // System.out.println(s + " -in if");
            }
            else {
                bw.write(s);
                break;
            }
        }
        reader.close();
        fw.close();
        reader.close();
    }
}
Everything works, it takes file name from the console (though you have to include the file type extension and not sure if the is the right way or not), it creates the file in the proper location, it takes lines from the console until "exit" is input and then ends like it supposed to, but when I go to look at the file it is completely blank...