private void outputEightPuzzleData(final String filename, final DataOutputStream dos) {
		System.err.print("Writing file...");
		final Iterator<Entry> listIter = this.stateToCostEntries_8_puzzle.iterator();
		if (filename == null) {
			// Write values to stdout. User can redirect stdout to a file, if desired.
			int i = 1;
			while (listIter.hasNext()) {
				final Entry entry = listIter.next();
				final long config = entry.getKey();
				System.out.println(i + "," + config + "," + entry.getValue() + ","
						+ Utility.longToString(config, this.numOfTiles));
				++i;
			}
		} else {
			int i = 0;
			try {
				while (listIter.hasNext()) {
					final Entry entry = listIter.next();
					dos.writeLong(((Long) entry.getKey()).longValue());
					dos.writeByte(((Byte) entry.getValue()).byteValue());
					++i;
				}
			} catch (final IOException ioe) {
				System.err.println("Error: Cannot write entry " + i + " to file.");
				System.exit(1);
			} finally {
				try {
					if (dos != null) {
						dos.close();
					}
				} catch (final IOException ioe) {
				}
			}
		}
		System.err.println("done");
	}