public static void main(String[] args) {
		log = new Log();
		options = new OptionParser();
		options.parse(args);
		log.setPath(options.logPath);

		// if files == null -> read from stdin
		List<File> files = options.getFiles();
		List<IREntry> irEntries = new ArrayList<IREntry>();

		try {
			IRProcessor irProcessor = new IRProcessor();
			
			// if option '-stdin' is set -> read from standard input stream
			if (options.stdin) {
				BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			    String line;
			    
			    // loop while stdin is open and there's no empty line
			    System.err.println("Reading input from stdin: (one sentence per line; an empty line stops reading.)");
			    while ((line = in.readLine()) != null && !line.isEmpty())
			    	lines.add(line);
			    
			    // pass 'lines' ArrayList to irProcessor
			    System.err.println("Parsing input...");
				irEntries.add(irProcessor.parse(lines));
				    
				// writes log to a log file
				System.err.println("Parsing finished. Writing result to log file.");
				logToFile("stdin");
			}
			
			// if option '-stdin' is not set, '-file' must be -> read from File objects within 'files' ArrayList
			else {
			    for (File currentFile : files) {
					currentFileName = currentFile.getName();
					
					// pass 'currentFile' file object to irProcessor
					System.err.println("Parsing: " + currentFileName);
					irEntries.add(irProcessor.parse(currentFile));
					
					// writes log to a log file
					System.err.println("Parsing of " + currentFileName + " finished. Writing result to log file.\n");
					logToFile(currentFileName);
				}
		    }
			
			// if option '-db' is set -> write to database
			if (options.database != null) {
				// create database with name set by '-db' option or open it if it already exists
				DBManager dbManager = new DBManager(options.database);
				
				// open database, write every IREntry object from 'irEntries' List to it and close it afterwards
				System.err.println("open/create database '" + options.database + "' and update data.");
				for (IREntry irEntry : irEntries)
					dbManager.getEntityManager().persist(irEntry);
				dbManager.closeDB();
			}
			
			exit(0, null);
		} catch (Exception e) {
			log(e);
			exit(-1, currentFileName);
		}
	}