public void savePattern(Pattern pattern, String fn) {
		try {
			fn = "recordings/" + fn;

			FileWriter fw = new FileWriter(new File(fn));

			System.out.println("Saving pattern");

			fw.write(pattern.rightHanded + "\n");

			//for each frame in the pattern
			for (int i=0; i<pattern.length; i++) {
				if (i > 20)
					fw.flush();

				//write palm
				Vector[] palm = pattern.palmData.get(i);
				String s = "p ";

				//position
				s += palm[0].getX() + " ";
				s += palm[0].getY() + " ";
				s += palm[0].getZ() + " ";

				//direction
				s += palm[1].getX() + " ";
				s += palm[1].getY() + " ";
				s += palm[1].getZ();

				fw.write(s + "\n");

				//write fingers
				for (Vector[] finger : pattern.fingerData.get(i)) {

					if (finger[0] != null) {
						s = "1 ";

						//position
						s += finger[0].getX() + " ";
						s += finger[0].getY() + " ";
						s += finger[0].getZ() + " ";

						//direction
						s += finger[1].getX() + " ";
						s += finger[1].getY() + " ";
						s += finger[1].getZ();
					} else {
						s = "-1 ";
					}

					fw.write(s + "\n");
				}

				fw.write("\n");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}