fixes for wide character streams, use traits_type::eof() to detect eof
instead of checking for a negative return value