|If the lines are on the screen even while booting the computer, that can't be caused by a software problem.|
In any case it's probably a hardware problem.
If you have an iMac model that has a screen you can swivel, and you have swiveled it, your problem is probably caused by a a wire or wires getting damaged in the wiring between the video adapter and the display near where it swivels.
This same problem happens with laptops after the laptop has been opened and closed a lot - a wire or wires getting damaged in the wiring between the video adapter and the display near where the lid hinge is.
A search on the web for: iMac lines on screen
finds many "hits", including this one:
Apple iMac LCD Screen Lines
The iMac is Apple's mid-level desktop, featuring an integrated 17", 20" or 24" LCD monitor. The iMac's LCD flat screen display suffers from a manufacturing defect that creates vertical lines after several months of use. The number of lines seem to increase as time goes on, marring the user's viewing experience. Apple may refuse to replace or repair the screens because the screen lines typically appear just after the one-year warranty runs out, and some have been quoted prices of more than $700 to repair their computers.