Drop the `tmp.replace('\0', ' ')` above and just do `tmp.split('\0')`.