code: public static void writeLinesToFile(final File output, final List<String> input,
  		final String encoding) throws FileNotFoundException, IOException
  	{
  		final String lineSeparator = System.getProperty("line.separator");
  		try (FileOutputStream fos = new FileOutputStream(output);
  			OutputStreamWriter osw = (null == encoding)
  				? new OutputStreamWriter(fos)
  				: new OutputStreamWriter(fos, encoding);
  			PrintWriter out = new PrintWriter(osw);)
  		{
  			final int size = input.size();
  			final StringBuffer sb = new StringBuffer();
  			for (int i = 0; i < size; i++)
  			{
  				final String entry = input.get(i);
  				sb.append(entry).append(lineSeparator);
  			}
  			out.write(sb.toString());
  		}
  	}
docs: Writes the input from the collection into the file.
  
  @param output
  The file to write the lines.
  @param input
  The list with the input data.
  @param encoding
  The encoding.
  @throws FileNotFoundException
  is thrown if an attempt to open the file denoted by a specified pathname has
  failed.
  @throws IOException
  Signals that an I/O exception has occurred.