The file is not being printed out,what am I doing wrong?
<p>I have been trying to get the output of this code to be printed on a .txt file, however I getting an empty file as an output, but I see the correct results in the console, so the problem is with the StreamWriter I think.</p>

<p>So what am I doing wrong?</p>

<pre><code>package Hierarchies;

    public static void generateHierarchy() {

        Set&lt;Entry&lt;Long, Node&gt;&gt; iterator = graph.entrySet();
        int i =0;
        for(Entry&lt;Long,Node&gt; e : iterator) {
            System.out.println(i++ +" - " +e.getValue().firstParents());
        }

    }

    @SuppressWarnings({ "resource" })
    public static void main(String[] args) throws JWNLException {
        // TODO Auto-generated method stub
        dictionary = Dictionary.getDefaultResourceInstance();

        File dir = new File("C:/Users/D060891/Desktop/Thesis/sentencesNYT");

        for (File file : dir.listFiles()) {

            try {
                BufferedReader input = new BufferedReader(new FileReader(file));
                String line;

                while ((line = input.readLine()) != null) {
                    demonstrateListHelper(line);                              
                }
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }

        generateHierarchy();
        PrintStream out;
        try {
            out = new PrintStream(new FileOutputStream("output.txt"));
            System.setOut(out);
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
</code></pre>