UFP records profit in the second quarter