opened
svmk
username_0
Hello! To reproduce this bug you may use this project: 
https://github.com/username_0/test-async-std-bug

Download it and exeucte file `run-test.sh`

Steps to reproduce:
1. Download remote url `https://www.sec.gov/Archives/edgar/full-index/1994/QTR1/company.idx` by using `reqwest` library
2. Save it to file while downloading by using `async_std::fs::File`
3. Download remote url `https://www.sec.gov/Archives/edgar/full-index/1994/QTR1/company.idx` using `wget`
4. Compare files. It's differ!

Expected result:
Files must be equal.

Code to reproduce this bug:
```rust
use futures::stream::StreamExt;
use async_std::fs::File;
use futures::AsyncWriteExt;
use std::{fs::File as SyncFile, io::Write};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://www.sec.gov/Archives/edgar/full-index/1994/QTR1/company.idx";
    let client = reqwest::Client::new();
    let response = client.get(url).send().await?;
    let mut response_body = response.bytes_stream();
    let mut async_file = File::create("company.async.idx").await?;
    let mut sync_file = SyncFile::create("company.sync.idx")?;
    while let Some(buffer) = response_body.next().await {
        let buffer = buffer?;
        let _ = async_file.write(&buffer).await?;
        async_file.sync_all().await?;
        sync_file.write(&buffer)?;
    }
    return Ok(());
}
```
File was corrupted by async_std::fs::File
issue
created
jbr
username_1
I believe the issue here is the same as https://github.com/async-rs/async-std/issues/939#issuecomment-762092739 — you're doing `async_file.write(&buffer).await` ([Write::write](https://docs.rs/async-std/1.9.0/async_std/io/trait.Write.html#method.write)) instead of `async_file.write_all(&buffer)`([Write::write_all](https://docs.rs/async-std/1.9.0/async_std/io/trait.Write.html#method.write_all) — write doesn't necessarily write all of the contents. If you log the return value from write and compare it to the buffer.len(), there will be occasional discrepancies
comment