Why do U.S. firms hold much more cash now than they did 30 years ago? Prior empirical studies have discovered a statistically significant positive relationship between firm cash holdings and cash flow volatility. Such findings, however, are subject to endogeneity problems. In this paper, I construct a structural model of firm dynamics where cash provides a buffer against cash-flow shortfalls in the presence of costly external finance. My model finds that 63% of the increase in corporate cash holdings can be accounted for by the increase in cash flow volatility. The increase in cash flow volatility observed in the data arises from a decrease in the correlation between revenue and operating expenses. The model has a corresponding correlation parameter between the shocks on revenue and operating expenses and only this parameter is changed in the primary experiment. The decomposition of revenue and operating expenses is important and I show that other ways of modeling the cash flow volatility increase are both counterfactual and dampening. A regression using the model data then generates a coefficient on cash flow volatility similar to what was found in previous studies which suggests that the regression underestimates the true impact of volatility. Finally, I investigate the response of cash holdings to policy changes and the consequences of cash restrictions on firm value.