public void replaceWordsOfGivenLength(int length, String substring)
            throws IOException{
        for(int i = 0; i < text.numberOfParagraphs(); i++){
            Paragraph currParagraph = text.getParagraph(i);
            for(int j = 0; j < currParagraph.numberOfSentences(); j++){
                Sentence currSentence = currParagraph.getSentence(j);
                for(int k = 0; k < currSentence.numberOfSentenceElements(); k++){
                    SentenceElement currSentenceElement = currSentence.getSentenceElement(k);
                    if(currSentenceElement instanceof Word &&
                            ((Word) currSentenceElement).getNumberOfLetters() == length){
                        ((Word) currSentenceElement).setLetters(substring);
                    }
                }
            }
        }

        writeToFile("./temp.txt");
        loadTextFromFile("./temp.txt");
    }