Backport PR #25625 on branch 0.24.x (BUG: to_csv line endings with compression)
Backport PR #25625: BUG: to_csv line endings with compression
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=h1) Report
> Merging [#25663](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=desc) into [0.24.x](https://codecov.io/gh/pandas-dev/pandas/commit/05fe1dcc9112d3d935cfa43ccde891610dfa8a71?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25663/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           0.24.x   #25663      +/-   ##
==========================================
+ Coverage   92.39%   92.39%   +<.01%     
==========================================
  Files         166      166              
  Lines       52424    52424              
==========================================
+ Hits        48436    48437       +1     
+ Misses       3988     3987       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.83% <100%> (ø)` | :arrow_up: |
| #single | `42.9% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/25663/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NvbW1vbi5weQ==) | `72.86% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25663/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.13% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=footer). Last update [05fe1dc...f35fc7c](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=h1) Report
> Merging [#25663](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=desc) into [0.24.x](https://codecov.io/gh/pandas-dev/pandas/commit/05fe1dcc9112d3d935cfa43ccde891610dfa8a71?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/25663/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           0.24.x   #25663      +/-   ##
==========================================
+ Coverage   92.39%   92.39%   +<.01%     
==========================================
  Files         166      166              
  Lines       52424    52424              
==========================================
+ Hits        48436    48437       +1     
+ Misses       3988     3987       -1
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.83% <100%> (ø)` | :arrow_up: |
| #single | `42.9% <0%> (-0.01%)` | :arrow_down: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/io/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/25663/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL2NvbW1vbi5weQ==) | `72.86% <100%> (ø)` | :arrow_up: |
| [pandas/util/testing.py](https://codecov.io/gh/pandas-dev/pandas/pull/25663/diff?src=pr&el=tree#diff-cGFuZGFzL3V0aWwvdGVzdGluZy5weQ==) | `88.13% <0%> (+0.09%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=footer). Last update [05fe1dc...f35fc7c](https://codecov.io/gh/pandas-dev/pandas/pull/25663?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
