substitute logic corrected. old $line_in thrown away