My impression is that line infantry became obsolete some time around the mid-19th century due to advancements in artillery, rifle technology, machine guns, and industrial/increasingly mechanized supply chains that would eventually lead to the trench warfare of the western front of WWI.
However, I feel that there is a gap in the public perception of warfare in the decades preceding WWI. How did battles play out in conflicts like the Franco-Prussian War, Boer Wars, Spanish-American War, Russo-Japanese War, Mexican Revolution, the Balkan Wars, and the non-western fronts of WWI?
If the above list is overbroad, I would still appreciate specific descriptions of individual conflicts, or of whichever wars/battles are most useful in understanding the transition from line infantry to industrial warfare.
More can always be said on the matter, so if anyone has further insight on the matter, don't let this post stop you! More coverage of the wars not the American Civil War between 1815 to 1914 is useful. (Especially to me.)
For the meantime, OP, here's some previous posts for you.
It's also worth noting that WWI wasn't trenches from day 1, as u/elos_ also examines in this post. The WWI section of the FAQ also has a '1914' section dealing with the period before the trenches arose.