private void readFile(BufferedReader reader) throws IOException{
        startTime = System.nanoTime(); 
        textfields.setControlfile("Starting assembly ...");
        for ( String line; ( line = reader.readLine() ) != null; ) 
                {
                    textfields.setProgramfile(linecounter + " " + line);
                    linecounter++;
                    line = line.trim();
                    if (line.startsWith("define")){
                        line = line.replaceFirst("define", "");
                        line = line.trim();
                        if(line.startsWith("#")){
                            errorcounter++;
                            textfields.setControlfile((linecounter-1) + ": The number of operands for this opcode is incorrect.");
                            continue;
                        }
                        parts = line.split("\\s+");
                        try {
                            definitions.put(parts[0],Integer.parseInt(parts[1]));
                        }
                        catch(NumberFormatException e) {
                        errorcounter++;
                        textfields.setControlfile((linecounter-1) + ": The number of operands for this opcode is incorrect.");
                        }
                    }
                    else if(line.startsWith("#")){
                    }
                    else {
                        parts = line.split("\\s+");
                        if(parts.length==3){
                             definitions.put(parts[0],counter);   
                        }
                        for (String part : parts) {
                            if (part.startsWith("#")) {
                                break;
                            }
                            programMemory.add(part);
                            counter++;
                            //programMemory.remove("");
                        }
                        }
                }
        endTime = System.nanoTime();
        duration = endTime - startTime;
        seconds = (double)duration / 1000000000.0;
        if (errorcounter == 0){
            textfields.setControlfile("BUILD SUCCESSFUL. Assembly time: " + seconds + " sec.");
        }
        else{
           textfields.setControlfile("BUILD FAILED. Assembly time: " + seconds + " sec. Number of invalid statements: " + errorcounter); 
        }
    }