Walter Bernstein, a scriptwriter who was blacklisted in the 1950s for his Communist Party membership and two decades later skewered the McCarthy era in “The Front,” a film that starred Woody Allen in a rare semi-serious role and earned an Oscar nomination for best screenplay, died Jan. 23 at his home in Manhattan. He was 101. 

The cause was pneumonia, said his wife, literary agent Gloria Loomis.

Mr. Bernstein first published in the New Yorker at 20 and distinguished himself as a combat correspondent during World War II with the military weekly Yank. His best-selling book of war dispatches, “Keep Your Head Down” (1945), was lauded for its expertise with dialogue and propelled a film and TV writing career that lasted into his 90s.

He contributed to the Hollywood western “The Magnificent Seven” (1960) and movies such as “Fail-Safe” (1964), starring Henry Fonda as the U.S. president facing a nuclear holocaust, and “Semi-Tough” (1977), a comedy with Burt Reynolds and Kris Kristofferson as football players. 

Mr. Bernstein also co-wrote “The Molly Maguires” (1970), starring Sean Connery as a 19th-century Pennsylvania coal miner whose protests for better working conditions are violently suppressed. It was not a commercial success, even after Mr. Bernstein acceded to studio demands to tack on a love story. “It was very downbeat, I guess, for most people at the time,” he later told the Nomadic Press. “You know, the hero got hanged and the villain got rewarded.” 

The son of a Brooklyn schoolteacher, Mr. Bernstein came of age during the Depression and said he was drawn to communism to battle fascism in Europe as well as racial and economic injustices at home. Communism, he wrote in his 1996 memoir, “Inside Out,” “expressed what I wept for in movies, what moved and thrilled me the most: people fighting not only for themselves but for other people, and now for the whole world.”

He was one of many prominent figures whose livelihoods and relationships were upended amid the Red Scare of the 1950s — an era of political witch hunts in which Mr. Bernstein’s phone was tapped, his garbage was rifled through, and he was trailed by the FBI. It was nearly impossible to get off the blacklist without denouncing other alleged communists, an option he could not stomach.

He said the perception of fear was pervasive, but he also found it laughable that anyone would suspect the communists he knew of plotting a violent overthrow of the government. “No one I knew in the Party ever dreamed of it,” Mr. Bernstein wrote in his book. “Our meetings might have been less boring if they had.”

Nevertheless, he became unemployable under his own name from 1950 to 1958, and he asked friends to act as “fronts” to shield his identity as a writer. His work, although not his name, appeared on prestigious anthology shows such as “Studio One,” and he won awards he could not openly accept. At least one front earned a lucrative movie contract on the strength of Mr. Bernstein’s scripts. “Careers were made on my talent,” he acidly observed. 

“The Front” (1976) was based on that time of political hysteria. He originally wrote the film as a straightforward drama, but when he and a close friend, the once-blacklisted director Martin Ritt, shopped it around Hollywood, they were told the subject was commercial poison. 

It only was greenlighted after Mr. Bernstein retooled the script as a partial comedy, and Ritt persuaded Allen, the writer-director and comedy star who was then at his most bankable, to star.

“No responsible person in the movie industry ever offered me a serious role before,” Allen quipped to the New York Times. “The reason I did ‘The Front’ was that the subject was worthwhile. Martin Ritt and Walter Bernstein lived through the blacklist and survived it with dignity, so I didn’t mind deferring to their judgment.” 

Allen played a bookie who pretends, for a share of the profits, to be the author of TV scripts written by blacklisted writers. At first a political coward, he develops a conscience after a friend (played by the formerly blacklisted actor Zero Mostel) commits suicide. In the final scene, he utters a defiant profanity when hauled before the House Un-American Activities Committee. 

Reviews for “The Front” were uneven, with many critics noting its precarious hodgepodge of humor, tragedy and politics.

“Almost everything it does could have been done better,” Time magazine’s Richard Schickel wrote. “On the other hand, it is a very difficult movie to judge because it takes up a previously forbidden subject . . . and has the nerve, and grace, to take an absurdist view of that deplorable era.” 

Walter Saul Bernstein was born in Brooklyn on Aug. 20, 1919. By his telling, he was a sports and film fanatic who had only passing awareness of world affairs before he was selected at 16 for a study-abroad program in France. 

In Grenoble, he fell in with a group of English communists who engaged in impassioned discussions about the plight of the proletariat and the fight against Nazism. He saw striking workers all over the city singing the socialist anthem “The Internationale,” and Mr. Bernstein was soon brimming with revolutionary ardor.

He published a short work of fiction in the New Yorker in 1939, leading to regular contributions to the magazine’s “Reporter at Large” column after his Dartmouth College graduation the next year and his enlistment in the Army during World War II. The military made him a press agent for the Broadway show “This Is the Army,” Irving Berlin’s morale-boosting musical. 

Mr. Bernstein was supposed to publicize how the active-duty service members in the cast were, in fact, working as hard as all other recruits. That seemed to be undermined by his New Yorker article showing a comedian who specialized in double-talk leading a calisthenics drill: “Inhale! Outhale! Sidehale!”

A humor-impaired colonel threatened Mr. Bernstein with a court-martial. But New Yorker editor Harold Ross intervened with his good friend George Marshall, the Army chief of staff. Mr. Bernstein soon obtained a transfer to a new Army publication, Yank.

As a roving correspondent, he covered the brutal campaigns in Sicily and Italy. He also tramped a week over mountains in German-occupied Yugoslavia to obtain one of the first interviews by a U.S. newsman with the anti-fascist partisan revolutionary Josip Broz Tito.

The expedition to reach Tito, the future Communist strongman, was arduous but not without its cheerier moments. Mr. Bernstein recalled the partisans teaching him their patriotic marches, and they wanted him to reciprocate with rousing American songs. Stumped, he said the best he could do was “Buckle Down Winsocki,” from the Broadway musical “Best Foot Forward,” set in a military academy. 

With the success of “Keep Your Head Down,” he was lured to Hollywood with the promise of writing screen adaptations of works by Chekhov and Dostoyevsky, but instead he found himself roped into shared credit on a minor Burt Lancaster film noir called “Kiss the Blood Off My Hands” (1948).

He saw more promise in the new medium of television, and his speed and versatility as a writer made him attractive to producers. But assignments dried up in 1950 after his name appeared in the influential anti-communist pamphlet Red Channels.

With the help of a sympathetic CBS producer, Mr. Bernstein concocted schemes to avoid detection by the panicky network brass on the lookout for communist writers. 

Mr. Bernstein took a pseudonym, Paul Bauman, and the producer explained to his bosses that the author was a literary hermit who wrote from a mountaintop cabin in Colorado and did not have a phone. When that did not satisfy CBS executives, they arranged for Bauman to seek treatment in Switzerland for a rare tropical disease. Finally, when the ruse could go no further, the terminally ill Bauman jumped to his death from an alp. 

Mr. Bernstein described writing for “You Are There,” a CBS historical reenactment program hosted by Walter Cronkite, as one of his most rewarding jobs. He and other blacklisted scribes churned out story lines spotlighting historic examples of intolerance — including the anti-Semitic Dreyfus Affair and the persecution of Galileo for heresy.

They were intended as veiled commentaries on the Red Scare, a literary “guerrilla war,” Mr. Bernstein noted. The show was popular and showered with awards, none of which he could accept. But Mr. Bernstein defined success, under the circumstances, in other ways: “I was working.”

Even as Mr. Bernstein severed ties with the party after the Soviet invasion of Hungary in 1956, he continued using phantom names or fronts until the blacklist began to come undone amid legal challenges. His own reprieve was expedited by a studio chief who needed Mr. Bernstein’s services on two Sophia Loren movies — “That Kind of Woman” (1959) and “Heller in Pink Tights” (1960).

Mr. Bernstein’s later credits included “Paris Blues” (1961), starring Paul Newman and Sidney Poitier as American jazzmen in France; “Yanks” (1979) with Richard Gere as an American soldier in wartime England; and “The House on Carroll Street” (1988), a blacklist and Nazi drama with Kelly McGillis and Jeff Daniels. He also wrote and directed “Little Miss Marker” (1980), a flop remake of a Shirley Temple film.

Mr. Bernstein kept pitching ideas to cable networks through recent years, most in keeping with the social-justice concerns that defined his life. His teleplay for HBO’s “Miss Evers’ Boys” (1997), about the U.S. government’s use of unsuspecting Black men to test the effects of syphilis, earned an Emmy nomination. He also reworked “Fail-Safe” into a live CBS-TV adaptation for producer George Clooney in 2000.

His marriages to Marva Spelman, Barbara Lane and Judith Braun ended in divorce. In 1988, he married Loomis. In addition to his wife, survivors include two children from his first marriage, Joan Bernstein and Peter Spelman; three children from his third marriage, Nicholas Bernstein, TV director Andrew Bernstein and Pulitzer Prize-winning journalist Jake Bernstein; a stepdaughter, Diana Loomis; a sister; five grandchildren; and two great-grandchildren.

In his memoir, Mr. Bernstein wrote that the blacklist caused so much havoc and confusion with hidden identities that he often was praised by writer friends for excellent work he had nothing to do with.

“My denials were taken as signs of a becoming modesty,” he wrote. “There were certain advantages to this. It could take you far with attractive women who appreciated good writing. You had to choose, of course, between lust and honor, but that was no choice at all.”