The following code reads a bunch of .csv files and then combines them into one .csv file. I tried to `system.out.println` ... all datapoints are correct, however when i try to use the `PrintWriter` I get:

`Exception in thread "main" java.lang.OutOfMemoryError: Java heap space`. 

I tried to use `FileWriter` but got the same error. How should I correct my code?

```
public class CombineCsv {
    public static void main(String[] args) throws IOException {
        PrintWriter output  = new PrintWriter("C:\\User\\result.csv");
        final File file = new File("C:\\Users\\is");
        int i = 0;
        for (final File child: file.listFiles()) {
            BufferedReader CSVFile = new BufferedReader( new FileReader( "C:\\Users\\is\\"+child.getName()));
            String dataRow = CSVFile.readLine(); 
            while (dataRow != null) {
                String[] dataArray = dataRow.split(",");
                for (String item:dataArray) { 
                    System.out.println(item + "\t");
                    output.append(item+","+child.getName().replaceAll(".csv", "")+",");
                    i++;
                }
                dataRow = CSVFile.readLine(); // Read next line of data.
            } // Close the file once all data has been read.
            CSVFile.close();
        } 
        output.close();
        System.out.println(i);
    } 
}

```