Thanks for the suggestion to use proc_open. I reckon I should get more familiar with file streams.