Given a set of lines from the file we are patching, and a patch itself, this function will try and locate where in the file to apply that patch, and write the result of patching that file (if successful) to the output stream.