easier and less code duplication:

fprintf(fp, "%s", ip->name);
if (ip->next != NULL)
{
    fprintf(fp, "\n");
}