Here you can also use `with`:

```python
with open(to_file, 'w', 0) as output:
  for multivote in votes:
    write_prediction(multivote.combine(method, output))
```