diff --git a/textile/core.py b/textile/core.py
index 692cca4..9c6623f 100644
--- a/textile/core.py
+++ b/textile/core.py
@@ -230,7 +230,7 @@ class Textile(object):
         self.unreferencedNotes = OrderedDict()
         self.notelist_cache = OrderedDict()
 
-        if text == '':
+        if text.strip() == '':
             return text
 
         if self.restricted:
@@ -811,7 +811,7 @@ class Textile(object):
             """If we find a closing square bracket we are going to see if it is
             balanced.  If it is balanced with matching opening bracket then it
             is part of the URL else we spit it back out of the URL."""
-            # If counts['['] is None, count the occurrences of '[' 
+            # If counts['['] is None, count the occurrences of '['
             counts['['] = counts['['] or url.count('[')
 
             if counts['['] == counts[']']:

diff --git a/tests/test_github_issues.py b/tests/test_github_issues.py
index bf9c339..b8a8330 100644
--- a/tests/test_github_issues.py
+++ b/tests/test_github_issues.py
@@ -91,3 +91,9 @@ def test_github_issue_36():
     result = textile.textile(text)
     expect = '\t<p><a href="https://www.google.com/search?q=Chögyam+Trungpa">Chögyam Trungpa</a></p>'
     assert result == expect
+
+def test_github_issue_40():
+    text = '\r\n'
+    result = textile.textile(text)
+    expect = '\r\n'
+    assert result == expect

IndexError string index out of range on whitespace only string
When I try to process a string that is whitespace only, I get an `IndexError`:

```
In [1]: from textile import textile

In [2]: textile(' ')
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
```

Ref: https://github.com/textile/python-textile/issues/26
tests/test_github_issues.py::test_github_issue_40
tests/test_github_issues.py::test_github_issue_16 tests/test_github_issues.py::test_github_issue_17 tests/test_github_issues.py::test_github_issue_20 tests/test_github_issues.py::test_github_issue_21 tests/test_github_issues.py::test_github_issue_22 tests/test_github_issues.py::test_github_issue_26 tests/test_github_issues.py::test_github_issue_27 tests/test_github_issues.py::test_github_issue_28 tests/test_github_issues.py::test_github_issue_36