Use buffered IO for better performance