import java.io.*;
import java.util.Scanner;
public class CharWriteTest {
  public static void main(String[] args) {
    int id; String name, score;
    File ofile = new File("c:\\CharScore.txt");
    FileWriter f_write = null;
    BufferedWriter b_write = null;
    PrintWriter p_write = null;
    try {
      f_write = new FileWriter(ofile);
      b_write = new BufferedWriter(f_write);
      p_write = new PrintWriter(b_write);      
      System.out.println("Read from KB");
      System.out.println("===========================");
      do {
        System.out.print("id = ");
        id = new Scanner(System.in).nextInt();
        if (id != -1) {
           System.out.print("name = ");
           name = new Scanner(System.in).nextLine();
           System.out.print("score = ");
           score = new Scanner(System.in).nextLine();
           p_write.println(id+"\t"+name+"\t"+score);
        }
      } while (id != -1);
    }
    catch (IOException e){
      System.out.println(e);
    }
    finally {
      if (p_write != null)
        p_write.close();
      System.out.println("Data are saved to File : \n" + ofile);
      System.out.println("===========================");
    }
  }  
}