should help you out StreamWriter.Flush() can be called any time you need to clear the buffer, and the stream will remain open. StreamWriter.Close() is for closing the stream, at which point the buffer is also flushed.
using (var writer = new StreamWriter("somefilepath.txt"))
// write a bunch of stuff here
} // the streamwriter WILL be closed and flushed here, even if an exception is thrown.
C# .NET StreamWriter: How to skip lines when writing file using StreamWriter?
I hope this helps you . When the BufferedReader gets closed at the end of the try-with-resources block, System.in is also closed and it can't be reopened. You should open the reader once and keep it open somewhere where you can use it until your program is finished.