bugfix (was writing to output stream)