Wrote getline implementation to avoid dependency