I don't understand why all of you are telling him about '\r\n\, write(),..' instead of recommending to use take library which already has all problems resolved (python-gammu / wammu). When one will write custom templating stuff, you would also recommend him to take jinja.