title: Storing String input in a file
body: <p>Ok, before anyone starts flaming me for asking <em>"<strong>dumb</strong>"</em> questions, please note that I have pretty much exhausted every other option that <strong><em>I know of</em></strong> and come up empty handed. Still if you feel like it, please go ahead and downvote/report this question.</p>
  
  <p>Now, for those that <strong>care</strong></p>
  
  <p>I am trying to take a <code>String</code> input from user and store it into a file <strong><em>Text.txt</em></strong> which will be created in the current working directory.</p>
  
  <blockquote>
    <p>Following is the code</p>
  </blockquote>
  
  <pre><code>import java.io.BufferedWriter;
  import java.io.FileWriter;
  import java.util.Scanner;
  
  
  public class Encryption {
  
      public static void main(String[] args) throws Exception {
  
          System.out.println("Enter a String you wish to encrypt : ");
          new BufferedWriter(new FileWriter(".\\Text.txt")).write(new Scanner(System.in).nextLine());
          System.out.println("Done");
      }
  }
  </code></pre>
  
  <p>My problem is, the file is getting generated at the correct destination, but is always empty. I have tried it on multiple JDK versions and on different machines. Still getting the blank text file.</p>
  
  <p>Please tell me, what is it that I am doing wrong.</p>