File writing is not completed in java
<p>I am trying to write to a text file contentiously,  but I am not getting a correct output file.</p>

<p>My code is as follows:</p>

<pre><code>for (int p = 0; p &lt;= noiter; p++) {
    long startTime = System.currentTimeMillis();

    // Initialization and Usage Checking

    try {
        Date dt = new Date();

        SimpleDateFormat ft = new SimpleDateFormat("yyyy.MM.dd '_' hh.mm.ss");
        System.out.println(ft.format(dt));

        FileWriter fn = new FileWriter("D:/sam/output/output_" +
            ft.format(dt) + ".txt");
        BufferedWriter wrt = new BufferedWriter(fn);
        wrt.write("&lt;------output started here-----&gt;  ");
        wrt.newLine();
        wrt.close();
    }
}
</code></pre>
