Work around missing getline function in OS X 10.6

This patch provides getline like functionality and seems to fix compilation problems for some user.