added buffered I/O for accounting