title: Java code for file output is not working
body: <p>Here i have written a program. I want to get input by a scanner from system. Then I want to show output from file. But after giving input , a message " The file is modyfied by another program " is shown. But i cannot see anything in this file. Please give me a suggestion to solve the problem.</p>
  
  <pre><code>package eighthLecture;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.util.Scanner;
  
  public class Filetester {
  public static void main(String[] args) {
      File outFile = new File("C:/Users/nafiulislam/Desktop/naficlass.txt");
          try {
  
              FileWriter fileWriter=new FileWriter(outFile);
              Scanner scanner = new Scanner(System.in);
  
              while(scanner.hasNext()){
              String tempString = scanner.nextLine(); 
              System.out.println(tempString);
              fileWriter.write(tempString);
          }
              fileWriter.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>