changed location to bufferIndex in the write method of FileSystem