private void writeOutput(List<List<Gate>> layersOfGates) {
		BufferedWriter fbw = null;
		try {
			fbw = new BufferedWriter(new OutputStreamWriter(
					new FileOutputStream(outputFile), charset));
			int[] intHeaders = circuitParser.getOutputHeader(layersOfGates);
			String header = "";

			for (int i = 0; i < intHeaders.length; i++){
				header += (intHeaders[i] + "");
				if (i != intHeaders.length - 1){
					header += " ";
				}
			}
			fbw.write(header);
			fbw.newLine();

			/*
			 * Write the gates the the file, one layer at a time
			 */
			for(List<Gate> l: layersOfGates){
				// Write the size of the current layer
				fbw.write("*" + l.size()); 
				fbw.newLine();

				// Write the gates in this layer
				for(Gate g: l){
					String gateString = layersOfGates.indexOf(l) + " " + g.toString();
					fbw.write(gateString);
					fbw.newLine();
				}
			}

		} catch (IOException e) {
			e.printStackTrace();
		} finally { 
			try {
				fbw.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}