sed in OSX chokes on b command when not followed by newlines.

Also, cat is not needed.

As suggested by Scrutinizer @ http://stackoverflow.com/a/15470635/151465