using reader/writer instead of streams