in reply to Modifying File in the Middle

  1. Open fileC for writing.
  2. Open fileB for reading.
  3. Read in fileB up to and including the SEARCHPATTERN.
  4. Write everything you've read into fileC.
  5. Open fileA for reading.
  6. Read in fileA, write it to fileC.
  7. Close fileA.
  8. Read the rest of fileB, writing it to fileC.
  9. Close fileB.
  10. Close fileC.
  11. Rename fileC to fileB.
Or in an (untested) Perl/shell one-liner:
perl -ne 'print; print `cat fileA` if /SEARCHPATTERN/' fileB > fileC & +& mv fileC fileB