Added helper functions for reading / writting streams