anchor.diff:        return _closeCompleter.future;
       }
       _closed = true;
  +
       void done() {
         _closeCompleter.complete();
         _controller.close();
       }
  -    if (_openedFile != null) {
  -      _openedFile.close()
  -          .catchError(_controller.addError)
  -          .whenComplete(done);
  -      _openedFile = null;
  -    } else {
  -      done();
  -    }
  +
  +    _openedFile.close()
  +        .catchError(_controller.addError)
  +        .whenComplete(done);
       return _closeCompleter.future;
     }
   
     void _readBlock() {
       // Don't start a new read if one is already in progress.
       if (_readInProgress) return;
  +    if (_atEnd) {
  +      _closeFile();
  +      return;
  +    }
       _readInProgress = true;
       int readBytes = _BLOCK_SIZE;
       if (_end != null) {
  
positive.code:   final Completer _closeCompleter = new Completer();
  
    // Has the stream been paused or unsubscribed?
    bool _paused = false;
    bool _unsubscribed = false;
  
    // Is there a read currently in progress?
    bool _readInProgress = false;
    bool _closed = false;
  
    // Block read but not yet send because stream is paused.
    List<int> _currentBlock;
  
    _FileStream(this._path, this._position, this._end) {
      _setupController();
    }
  
    _FileStream.forStdin() : _position = 0 {
      _setupController();
    }
  
    StreamSubscription<List<int>> listen(void onData(List<int> event),
                                         {Function onError,
                                          void onDone(),
                                          bool cancelOnError}) {
      return _controller.stream.listen(onData,
                                       onError: onError,
                                       onDone: onDone,
  
negative.code:   }
  
    void _start() {
      if (_position < 0) {
        _controller.addError(new RangeError("Bad start position: $_position"));
        _controller.close();
        return;
      }
  
      void onReady(RandomAccessFile file) {
        _openedFile = file;
        _readInProgress = false;
        _readBlock();
      }
  
      void onOpenFile(RandomAccessFile file) {
        if (_position > 0) {
          file.setPosition(_position)
              .then(onReady, onError: (e, s) {
                _controller.addError(e, s);
                _readInProgress = false;
                _closeFile();
              });
        } else {
          onReady(file);
        }
      }
  
      void openFailed(error, stackTrace) {
        _controller.addError(error, stackTrace);
        _controller.close();
        _closeCompleter.complete();
      }
  
      if (_path != null) {
        new File(_path).open(mode: FileMode.READ)
            .then(onOpenFile, onError: openFailed);
      } else {
        try {
          onOpenFile(_File._openStdioSync(0));
        } catch (e, s) {
          openFailed(e, s);
        }
      }
    }
  }
  
  