title: printWritter issue in Java
body: <p>I have a question regarding to printWrttier with String output, here is my code:</p>
  
  <pre><code>     import java.io.File;
       import java.io.FileNotFoundException;
       import java.io.PrintWriter;
       import java.util.Scanner;
  
  
      public class Out {
  
          public static void main(String[] args) {
              try {
                  File a=new File("C:/Users/Acer/Desktop/tyty.txt");
                  PrintWriter out=new PrintWriter(a);
                  Scanner c=new Scanner(System.in);
                  while(c.hasNextLine()) {
                      out.printf("%s",c.nextLine());
                  }
                  c.close();
                  out.close();
                  System.out.println("input written into file successfully!");
              } catch(FileNotFoundException e) {
                  System.out.println("The file not found");
              }
          }
      }
  </code></pre>
  
  <p>However, when I input some random String such as a b c d in the console, it has no response at all, I expect it to print out "input written into file successfully!", then I can see my input is shown up in the text file, but which part in my code cause the error?</p>
  
  <p>P.S the ctrl+c is not working here, as it is not killing the loop.</p>