I can only really speak with any certainty on mid 1800s American combat, so with that in mind, my answer will doubtless ignore earlier and later examples of proto-trench warfare.
The concept of line battle being two sides blazing into each other at close distance isn't very accurate. Even in "line warfare," the lines are manuvering, attempting to prevent the enemy from manuvering, blocking lines of approach and supply, and very importantly, building trenches (and redans.... and redoubts... you get the idea). When on an open field, the large formations use terrain for cover, and when facing direct fire use natural cover. By the American Civil War (and probably before it), soldiers were taught how to load and shoot kneeling and lying down. The effectiveness of trench warfare was known to 19th century tacticians, but it's tactical effectiveness was thought (broadly speaking) to come with a negative impact on morale. There was a longstanding tradition at least in the American military that if soldiers entrenched themselves, it would lower their morale. Conversely, it was thought that an enthusiastic charge or offensive action would or could boost morale. A possibly oversimplified example: In 1864, Confederate General Joseph Johnston was replaced by Confederate General John Hood, largely because the defensive nature of Johnston's handling of the Army of Tennessee. It's unlikely that these defenses would have worked in the long run, but it certainly would have been less immediately disastrous than the offensive Nashville Campaign the army was sent on after Atlanta fell.
It seems it wasn't that trench warfare was ineffectual because of muskets, it was that doctrine conflicted with modern (to the time) capabilities. Likewise, "line warfare" died slowly even well into the First World War. With hindsight, it's easy to dismiss "Napoleonic" tactics as old-fashioned and outdated even by the 1850's with significant improvements to musket ammunition making standard-issue rifled arms near-universal and with significantly improved accuracy, range, and rate of fire. Likewise improvements to artillery guns and ammunition increased their effectiveness-- and even several early Machine guns were used by the 1860's. Even so, these tactics worked, they had worked, and if a field commander tried something tactically new based on an assumption about some new-fangled technology that didn't work-- it would take some explaining to the higher-ups that likely gave him conflicting orders.
It's important to note that the US Army elected to adopt single-shot breechloading muskets over repeating rifles as standard arms, even though repeating arms proved themselves devastatingly effective in the Mobile and Nashville campaigns at the end of the Civil War. When the first magazine fed rifles were adopted by the US Army, they still had magazine cutoff levers for single-loading. Old habits die hard, especially when peoples lives are at stake.
All that being said, in 1914 that's pretty much how it was. The line of trenches we associate with WW1 is largely the product of frantic maneuvering and attempting to exploit enemy flanks with mounted cavalry. Verdun came about from hundreds of learned lessons from countless fights, reports, observations, and compromises. The bolt action rifles were important in determining that doctrine, as were the Machine guns and the significantly improved Artillery-- but repeaters had been in serious use since at least 1864, the bolt action seems to have had comparatively little impact on tactics.