fix rtyaml for files that decrease in size

bug caused by 31f5c2e685fe9414404b55d8a06008d9b4ba370b by opening a file with r+ without truncating its contents