Use +rb switches when reading in file for checking existence of YAML header.

Fixes #2228.
Only read in 5 bytes when checking for YAML header.

#2211 #2210