Remove leading and trailing empty lines, without removing leading whitespace on the first actual line.
$ diff codecolorer.php.old codecolorer.php
220c220,221
< $text = trim($text);
---
> $text = preg_replace('/^( *\r?\n)+/', '', $text);
> $text = preg_replace('/\r?\n *$/', '', $text);