The retailer also swung to a profit in the second quarter.