This code will work:
def highlight(data):
for word in data.split():
if word[0] == "#":
print "<FONT COLOR=\"brown\">" + word + "</FONT>",
else:
print word,
highlight("""hello world this
is a #test that i am #writing.""")
This will split the text up by newlines and by whitespace.