Scottish finance secretary resigns over text messages