Posix locking writing tuples

Writes result tuples in binary into a single file using posix locks.
Fixes previous writing tuples for large amounts of results.