replace strsep with a custom code

- replace strsep with a custom version of fgets which
  splits a big string into independent lines.