In emerging market economies (EMEs), capital inflows are associated to productivity booms. However, the experience of advanced small open economies (AEs), like the ones of the Euro Area periphery, points to the opposite, i.e., capital inflows lead to lower productivity, possibly because of entry of less productive firms. We measure capital flow shocks as exogenous variations in world real interest rates. We show that, in the data, lower real interest rates lead to lower productivity only in AEs, whereas the opposite holds for EMEs. We build a business cycle model with firms' heterogeneity, financial imperfections and endogenous productivity. The model combines a cleansing effect, stemming from capital outflows (inflows), with an original sin effect, whereby capital outflows (inflows), via a real exchange rate depreciation (appreciation), decreases (increases) the opportunity cost of producing for less productive firms and the borrowing ability of the incumbent, marginally more productive firms. The estimation of the model reveals that a low trade elasticity combined with high (low) firms' productivity dispersion in EMEs (AEs) are crucial ingredients to account for the different effects of capital flows across groups of countries. The relative balance of the cleansing and the original sin effect is able to simultaneously rationalize the evidence in both EMEs and AEs.