package com.codegym.task.task13.task1319;


Writing to a file from the console


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

        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 {
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...