Display post excerpt instead of content, if available

Change line 9 to:

$content = get_the_excerpt();

the_excerpt() echoes the excerpt. get_the_excerpt() returns it.