Place the fragments into the program, so that the program will get lines from a text file, display them…