Rollup merge of #51628 - euclio:line-writer, r=frewsxcv
Rollup merge of #51628 - euclio:line-writer, r=frewsxcv

use checked write in `LineWriter` example

The example was wrong because it didn't check the return value of
`write()`, and it didn't flush the buffer before comparing the contents
of the file.

Fixes #51621.

aidancully/rust,GBGamer/rust,graydon/rust,GBGamer/rust,aidancully/rust,graydon/rust,GBGamer/rust,graydon/rust,graydon/rust,GBGamer/rust,graydon/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,aidancully/rust,aidancully/rust,aidancully/rust,GBGamer/rust,GBGamer/rust,graydon/rust