protected static String getLine() throws IOException{
		String input;

		if (replayIn != null && controlInput) {
			// get a packet from the replay input file
			Packet line;
			try {
				line = getPacket();
			} catch (CorruptPacketException e) {
				throw new ReplayException("Error while reading replay file");
			}

			// verify that the packet is a user packet
			if (Replay.isUserPacket(line)) {
				input = Utility.byteArrayToString(line.getPayload());
			} else {
				throw new Replay.ReplayException("Expected user input, got: " + line.toString());
			}

			System.out.println("Replaying user input: '" + input + "'");
		} else {
			// get a line from the keyboard
			input = keyboard.readLine();
		}

		if (replayOut != null) {
			// record the user input to the replay output file
			try {
				if (input != null) {
					replayOut.write(Replay.getUserPacket(input).pack());
				} else {
					replayOut.write(Replay.getUserPacket("").pack());
				}
			} catch (IOException e) {
				throw new ReplayException("Error while writing replay file");
			}
		}

		return input;
	}