Fix for 2818.

The ReadWriteConnection logic wasn't up to par; it appears as though some corruption could possibly occur in cases where transient data sources were used, and were called to frequently together. This has been solved by rewriting ReadWriteFile from the ground up, and using a proper queue. Reads are blocking, writes are not, so this should improve general performance for typical use cases where reads and writes are not directly following each other. In worst case, performance will be the same.

Also, foreach() now supports the ArrayAccess interface instead of CArray specifically. This makes it work more like a java enhanced for-loop, in that it can handle a more generic "iterable" instead of just arrays.