import os print("starting the pruning process") scanning = "sudo scanimage --resolution 300 --mode color -o image.png" os.system(scanning) os.system("tesseract image.png image -l eng") fantasyname = open("image.txt" , "r") fantasyname = fantasyname.readlines() text = open("image.txt", "r").read() print(text) print("------") lines = text.split("\n") for line in lines: dotprint = f'echo "{line}" >/dev/usb/lp0' os.system(dotprint) #for line in fantasyname: #line = line.split(" ") #for l in line: #if l!="" or l != ['\n', '\r\n']: #print(l) #os.system("echo '"+l+"' > /dev/usb/lp0")