I think you are writing the ones and zeros as bytes, when you should be writing them out as bits.
Here's what you should do to make your program faster. set a counter like i to 0, and then each time you perform a subtraction, do byte_value |= 0 [or 1] << i; i = (i + 1) % 8. Then only do a write after every 8 iterations. Although, you can make the writing process even faster by waiting until you fill thousands of bytes like this, and then just write them all at once in one batch.
This will depend on the amount of RAM you have, of course.
However, That's what I did, I wrote 2^26 keys at once. Ate up at highest point, 14GB of RAM. If limited RAM you could do the counter as you suggested.
I have found a key in the 44 bit range in about 3-4 minutes, 5 or 6 times. It's an interesting script.
It's interesting in the way it can store massive amounts of "keys" in such a little file. For 2^26 keys, it only uses a file size of 8,192 kb. That is impressive.
The searching method is not great in terms of speed.
Also, you do not/should not use a start range of 1 (unless you are subtracting from original key and shrinking the key).
When I generated 2^26 keys with a num = 64 option, I set the start range to 8796093022208-(2^26-64) = 8796025913408. I do not know where the key is but I know it's max (17592186044415) and it's minimum (8796093022208) and since my subtraction was set at 1 (sequential with no steps such as using a subtraction as 7 or 10, etc) I know the target priv/pubkey will only be from Target down to - 2^26 (keys generated) - 64 (num option).
start (min) = 8796025913408
end (max) = 17592186044415
That's how I approached this script when running tests.
You could also speed the script up using an upfront pub subtraction to cut the range in half. Example, if we know the key is in the 44 bit range, we can do an upfront subtraction of 0x80000000000, and then use that newly generated pub in this script and then search in a max 43 bit range.
Now to ponder how to add this script's storage size function to an existing GPU script...