try { File file = new File(filePath+\"usedcommands.txt\"); if (!file.exists()) { file.createNewFile();
Pass true as a second argument to FileWriter to turn on "append" mode.
FileWriter fw = new FileWriter(file.getAbsoluteFile(), true);