Modified to accept line-separated text file as input