Better error message if writing read-only streams

This fixes #245