Don't rewrite if the pointer is already 0

Not all streams support rewind(), this prevents the error "rewind(): stream does not support seeking".