Replace str type on basestring.
outfile parameter is optional now.