Handle stream_get_contents() returning partial results

Probably closes #72.