Your reply shows almost exactly how I did it at first! However, I now realise that it failed to work because I hadn't imported streams, as your snippet shows, so thanks for that.
The import means that it now builds and runs. It does crash though, so I'll have to look into that, but it is a start.
