Fix issue with writing str to file in python 3
Fix whitespace issue