private void checkAndFixUpdateFile(String updatesFilename) throws Exception {
		FileReader updatesFR = new FileReader(updatesFilename);
		BufferedReader updatesBR = new BufferedReader(updatesFR);

		String update = updatesBR.readLine();

		while (update != null) {
			String str = update;
			for (int i = 1; i <= 2; i++) { // go to peer AS
				str = str.substring(str.indexOf("|") + 1);
			}
			String updateType = str.substring(0, str.indexOf("|"));
			if (updateType.equals("W")) { // there is no way to determine
											// correct AS for prefix withdrawals
											// as there is no AS Path
				update = updatesBR.readLine();
				continue;
			}
			for (int i = 1; i <= 2; i++) { // go to peer AS
				str = str.substring(str.indexOf("|") + 1);
			}

			try {
				// convert peerAS name to integer
				int peerAS = Integer
						.parseInt(str.substring(0, str.indexOf("|")));

				// go to AS Path
				str = str.substring(str.indexOf("|") + 1);
				str = str.substring(str.indexOf("|") + 1);

				int firstASinASPath;
				if ((str.indexOf(" ") == -1) || (str.indexOf(" ") > 5)) { // in
																			// case
																			// when
																			// there
																			// is
																			// only
																			// 1
																			// AS
																			// in
																			// AS
																			// path
					firstASinASPath = Integer.parseInt(str.substring(0,
							str.indexOf("|")));
				} else {
					firstASinASPath = Integer.parseInt(str.substring(0,
							str.indexOf(" ")));
				}

				// compare peerAS with first AS in AS Path
				if (peerAS != firstASinASPath) {
					logger.info("Update file with peerAS different from first AS in AS Path found: "
							+ updatesFilename);
					logger.info("file before conversion will be copied as filename.old");

					if (!simulate) { // in some cases I only want to
										// know which files need peerAS
										// fix, without fixing them
						fixUpdateFile(updatesFilename);
					}

					// file was converted, so stop searching for peerASes, that
					// needed to be fixed
					break;
				}

			} catch (Exception e) {
				logger.fatal("Cannot parse update: " + updatesFilename + ":"
						+ update, e);
				updatesBR.close();
				updatesFR.close();
				throw (new Exception("Cannot parse update: " + updatesFilename
						+ ":" + str, e));
			}

			update = updatesBR.readLine();
		}

		updatesBR.close();
		updatesFR.close();
	}