import java.io.*;
import java.util.*;
public class HookExample {
public static void main(String[] args) throws IOException {
final BufferedWriter out =
new BufferedWriter(new FileWriter("typed.txt"));
BufferedReader kbd =
new BufferedReader(new InputStreamReader(System.in));
Thread hook = new Thread() {
public void run() {
try {
out.write("Execution aborted at " + new Date());
out.newLine();
out.close();
} catch(IOException ioe) {
ioe.printStackTrace();
}
}
};
Runtime.getRuntime().addShutdownHook(hook);
String line;
while ((line = kbd.readLine()) != null) {
if (line.equals("halt"))
Runtime.getRuntime().halt(1);
out.write(line);
out.newLine();
}
Runtime.getRuntime().removeShutdownHook(hook);
out.close();
kbd.close();
}
}