public static void savePokemon()
	{
		String output ="savedata/"+idString+".pkmn";

		try
		{
			PrintWriter fout=new PrintWriter(new FileWriter(output));

			encryptionKey=0;

			if(VERSION.equals("Peaches"))
				fout.println("PDAE"+idString);
			else
				fout.println("CDAE"+idString);

            for (Pokemon aPartyPokemon : partyPokemon) {
                if (aPartyPokemon == null) {
                    fout.println("null");
                } else {
                    //Header
                    if (VERSION.equals("Peaches"))
                        fout.println("PDAE" + aPartyPokemon.idNumber);
                    else
                        fout.println("CDAE" + aPartyPokemon.idNumber);

                    //Strings
                    fout.println(aPartyPokemon.species);
                    fout.println(aPartyPokemon.nickname);
                    fout.println(aPartyPokemon.originalTrainer);
                    fout.println(aPartyPokemon.status);
                    fout.println(aPartyPokemon.substatus);
                    fout.println(aPartyPokemon.move[0]);
                    fout.println(aPartyPokemon.move[1]);
                    fout.println(aPartyPokemon.move[2]);
                    fout.println(aPartyPokemon.move[3]);

                    //Integers
                    fout.println(Integer.toBinaryString(aPartyPokemon.level));
                    encryptionKey += aPartyPokemon.level;
                    fout.println(Integer.toBinaryString(aPartyPokemon.exp));
                    encryptionKey += aPartyPokemon.exp;
                    fout.println(Integer.toBinaryString(aPartyPokemon.health));
                    encryptionKey += aPartyPokemon.health;
                    fout.println(Integer.toBinaryString(aPartyPokemon.healthMax));
                    encryptionKey += aPartyPokemon.healthMax;
                    fout.println(Integer.toBinaryString(aPartyPokemon.HP_EV));
                    encryptionKey += aPartyPokemon.HP_EV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.ATK_EV));
                    encryptionKey += aPartyPokemon.ATK_EV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.DEF_EV));
                    encryptionKey += aPartyPokemon.DEF_EV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.SPCL_EV));
                    encryptionKey += aPartyPokemon.SPCL_EV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.SPEED_EV));
                    encryptionKey += aPartyPokemon.SPEED_EV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.HP_IV));
                    encryptionKey += aPartyPokemon.HP_IV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.ATK_IV));
                    encryptionKey += aPartyPokemon.ATK_IV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.DEF_IV));
                    encryptionKey += aPartyPokemon.DEF_IV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.SPCL_IV));
                    encryptionKey += aPartyPokemon.SPCL_IV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.SPEED_IV));
                    encryptionKey += aPartyPokemon.SPEED_IV;
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PP[0]));
                    encryptionKey += aPartyPokemon.TRUE_PP[0];
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PP[1]));
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PP[2]));
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PP[3]));
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PPMAX[0]));
                    encryptionKey += aPartyPokemon.TRUE_PPMAX[0];
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PPMAX[1]));
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PPMAX[2]));
                    fout.println(Integer.toBinaryString(aPartyPokemon.TRUE_PPMAX[3]));

                    //Booleans
                    fout.println(aPartyPokemon.IS_TRADED);
                }
            }

            for (Pokemon aPcPokemon : pcPokemon) {
                if (aPcPokemon == null) {
                    fout.println("null");
                } else {
                    //Header
                    if (VERSION.equals("Peaches"))
                        fout.println("PDAE" + aPcPokemon.idNumber);
                    else
                        fout.println("CDAE" + aPcPokemon.idNumber);

                    //Strings
                    fout.println(aPcPokemon.species);
                    fout.println(aPcPokemon.nickname);
                    fout.println(aPcPokemon.originalTrainer);
                    fout.println(aPcPokemon.status);
                    fout.println(aPcPokemon.substatus);
                    fout.println(aPcPokemon.move[0]);
                    fout.println(aPcPokemon.move[1]);
                    fout.println(aPcPokemon.move[2]);
                    fout.println(aPcPokemon.move[3]);

                    //Integers
                    fout.println(Integer.toBinaryString(aPcPokemon.level));
                    encryptionKey += aPcPokemon.level;
                    fout.println(Integer.toBinaryString(aPcPokemon.exp));
                    encryptionKey += aPcPokemon.exp;
                    fout.println(Integer.toBinaryString(aPcPokemon.health));
                    encryptionKey += aPcPokemon.health;
                    fout.println(Integer.toBinaryString(aPcPokemon.healthMax));
                    encryptionKey += aPcPokemon.healthMax;
                    fout.println(Integer.toBinaryString(aPcPokemon.HP_EV));
                    encryptionKey += aPcPokemon.HP_EV;
                    fout.println(Integer.toBinaryString(aPcPokemon.ATK_EV));
                    encryptionKey += aPcPokemon.ATK_EV;
                    fout.println(Integer.toBinaryString(aPcPokemon.DEF_EV));
                    encryptionKey += aPcPokemon.DEF_EV;
                    fout.println(Integer.toBinaryString(aPcPokemon.SPCL_EV));
                    encryptionKey += aPcPokemon.SPCL_EV;
                    fout.println(Integer.toBinaryString(aPcPokemon.SPEED_EV));
                    encryptionKey += aPcPokemon.SPEED_EV;
                    fout.println(Integer.toBinaryString(aPcPokemon.HP_IV));
                    encryptionKey += aPcPokemon.HP_IV;
                    fout.println(Integer.toBinaryString(aPcPokemon.ATK_IV));
                    encryptionKey += aPcPokemon.ATK_IV;
                    fout.println(Integer.toBinaryString(aPcPokemon.DEF_IV));
                    encryptionKey += aPcPokemon.DEF_IV;
                    fout.println(Integer.toBinaryString(aPcPokemon.SPCL_IV));
                    encryptionKey += aPcPokemon.SPCL_IV;
                    fout.println(Integer.toBinaryString(aPcPokemon.SPEED_IV));
                    encryptionKey += aPcPokemon.SPEED_IV;
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PP[0]));
                    encryptionKey += aPcPokemon.TRUE_PP[0];
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PP[1]));
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PP[2]));
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PP[3]));
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PPMAX[0]));
                    encryptionKey += aPcPokemon.TRUE_PPMAX[0];
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PPMAX[1]));
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PPMAX[2]));
                    fout.println(Integer.toBinaryString(aPcPokemon.TRUE_PPMAX[3]));

                    //Booleans
                    fout.println(aPcPokemon.IS_TRADED);

                }
            }

			fout.println(""+encryptionKey);
			fout.close();

			saveEncryptionKey(output,encrypt(output));
			System.out.println("Pokemon File signed and exported.");
		}
		catch(Exception e){e.printStackTrace(); System.out.println("Error in writing Pokemon data.");}
	}