refactor findNoMainError

This is a followup to #1178.

- use fread/fwrite with 64K buffer

- wrap read buffer at newline to not
  split and miss the error message

- avoid hang when linker output exhausts
  the OS pipe buffer