Catch TypeError in case COLUMNS is empty
Fix typo in _write_with_fallback
Minor pep8 issues