as Iraqi troops advanced near their remote village outside militant-held Mosul. But after the Islamic State fighters fled and Iraqi troops didn't appear, their tiny supply of food quickly ran out, and the family had to flee to search for territory firmly under government control.
When the Mosul offensive began a week ago, departing IS fighters warned villagers to stay off the roads and surrounding fields, which the militants had mined. So Khalaf waited until she saw a passing shepherd, and then she and her family made the eight-hour walk out of no man's land behind a herd of sheep.
"We were starving," she said. They had watched the start of the offensive on TV and thought Iraqi forces were on the way, but the troops' progress has been slow, and Mosul's southern approach is littered with dozens of villages, some with no more than 20 homes.
Eventually, Khalaf couldn't produce enough breast milk for her infant daughter. "I started giving her goat's milk, but then the goat died," she said.
Mosul, the largest city controlled by the Islamic State group, is still home to more than 1 million civilians. The government and international aid groups fear that a sudden mass exodus will overwhelm the few camps set up on its outskirts.
The massive offensive is expected to take weeks, if not months, and with supply routes cut off by the fighting, many civilians may not be able to stay in place for long. Driven by fear or hunger, many are already putting themselves in grave danger and are complicating the campaign to expel the militants from the city, which fell to IS in 2014.
More than 5,600 people have already fled areas near Mosul, according to the International Organization for Migration, with most heading through IS-run territory toward the Syrian border, rather than in the direction of the advancing troops, who are converging from the north, east and south.
Camps have been set up to accommodate 60,000 people, but about 200,000 are expected to be displaced in the first weeks of the offensive, according to the Norwegian Refugee Council.
Both the Iraqi government and Kurdish authorities are mired in an economic crisis brought on by low oil prices and say they do not have the resources to care for such a large number of displaced people. So they have urged everyone to stay put.
"We have a comprehensive plan for the evacuation of the civilians," said Maj. Gen. Qassim al-Maliki, the head of the Iraqi army's 9th Division. "The plan is to keep them in their houses until it becomes safer."
That means huddling indoors, often with no electricity or running water, as explosions and gunfire echo outside. Those living near the front lines are often out of reach of aid groups.
Those who somehow manage to cross the battle lines, like Khalaf's family, face other challenges.
The Kurds have taken in hundreds of thousands of people, but Sunni Arabs, who make up most of Mosul's population, are viewed with suspicion. When IS militants attacked the Kurdish-controlled city of Kirkuk last week, a senior Kurdish commander immediately speculated the attackers had infiltrated the city disguised as fleeing civilians.
"Many of (the displaced civilians), I'm sure they are working with ISIS," said Kemal Kerkuki, a commander with the Kurdish forces, known as peshmerga. He said his forces arrested one recently who confessed to being part of a sleeper cell.
"I have told the authorities many times to open a big camp and put all of (the people fleeing IS) there so we can control them," he said.
In past operations against IS, Iraqi security forces have been accused of abuses of civilians fleeing militant-held territory. Iraqi armed groups "have committed serious human rights violations, including war crimes, by torturing, arbitrarily detaining, forcibly disappearing and extrajudicially executing thousands of civilians," the human rights group Amnesty International reported this month.
Fatima Abdullah, whose husband was detained for security screening at the Dibaga Camp this month after they fled their village near Mosul, said she understands the need for a vetting process. "I don't blame them, it's their right," she said.
She said she's able to visit her husband daily, but they are only able to see each other and speak through a chain-link fence.
"They are treating us well here," Abdullah said as some of her older children lined up to receive a hot evening meal in the school yard where they have been staying. "But we're also scared. We don't know what our destiny is."
When Khalaf and her family arrived in Qayara after following the sheep out of their village, she was exhausted and her children were hungry. Two of her young daughters ate handfuls of stale rice from a pile of food that had been discarded on the side of the road. Another child started to scream and cry, begging to return home.