pub fn lock_write_err<B>(bytes: B) -> Result<()> where B: AsRef<[u8]>,
The function will flush stderr when done.