Private mortgage insurer MGIC Investment Corp. (MTG) swung to a second-quarter loss of $151.7 million, or 75 cents a share, as the company reported fewer cured loans and paid more claims on mortgages that fell into distress. The Milwaukee-based company, which is the largest insurer of mortgages for Fannie Mae and Freddie Mac, earned $24.6 million, or 13 cents a share, for the year-earlier second quarter. MGIC's revenue fell to $367 million for the three months ended June 30 from $406.4 a year ago. Losses on claims rose to $459.6 million for the quarter, up from $320.1 million last year. MGIC fared better in the first three months of the year than the most recent period. For the first six months of 2011, MGIC reported a loss of $185.4 million, deeper than a loss of $125.5 million last year. Meanwhile, the firm wrote $3.1 billion in new insurance during the second quarter, up from $2.7 billion a year ago. The government's Home Affordable Refinance Program created enough activity in the first half to account for $1.5 billion in business at MGIC, compared to $1.3 billion a year earlier. Write to Kerri Panchuk.