@Override
	public void run() {

		if (!fromInteractive) {
			System.out.println(introMessage);
		}

		System.out.println("\nFILE = " + file.getAbsolutePath() + "\n");

		// input scanner
		Scanner sc;
		try {
			sc = new Scanner(new FileReader(file));
		} catch (IOException e) {
			System.out.println("ERROR:\n\tFile not found.");
			return;
		}

		System.out.println("--- File begin ---");

		while (sc.hasNextLine()) {

			String expr = sc.nextLine().trim();
			System.out.println("\n> " + expr);

			if (expr.equalsIgnoreCase("fractional") || expr.equalsIgnoreCase("decimal")) {

				if (fractionalMode) {
					System.out.println("[FRACTIONAL MODE OFF]");
					fractionalMode = false;
				} else {
					System.out.println("[FRACTIONAL MODE ON]");
					fractionalMode = true;
				}

			} else {
				try {
					Fraction result = session.evaluate(expr);
					System.out.println("= " + (fractionalMode ? result.toString() : result.getDoubleValue()));
				} catch (ParseError pe) {
					System.out.println("PARSE ERROR:\n\t" + pe.getMessage());
					System.out.println("\n--- Aborted ---");
					return;
				} catch (ArithmeticException ae) {
					System.out.println("MATH ERROR:\n\t" + ae.getMessage());
					System.out.println("\n--- Aborted ---");
					return;
				}
			}
		}

		System.out.println("\n--- File end ---");
	}