Writing and erasing thermal head