Fix some formatting (pep8)
Make sure text is a string for file.contains, Fix #6817
Merge pull request #6836 from basepi/contains6817

Make sure text is a string for file.contains, Fix #6817